You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fonts.xml 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- $Id$ -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
  18. <document>
  19. <header>
  20. <title>Apache FOP: Fonts</title>
  21. <version>$Revision$</version>
  22. <authors>
  23. <person name="Jeremias Märki" email=""/>
  24. <person name="Tore Engvig" email=""/>
  25. <person name="Adrian Cumiskey" email=""/>
  26. </authors>
  27. </header>
  28. <body>
  29. <section id="intro">
  30. <title>Summary</title>
  31. <note>The FOP Font subsystem is currently undergoing a significant change.
  32. The details provided here especially related to the generation of FOP Font
  33. Metrics files and the FOP Font configuration are likely to change substantially
  34. in the future.
  35. </note>
  36. <p>The following table summarizes the font capabilities of the various FOP renderers:</p>
  37. <table>
  38. <tr>
  39. <th>Renderer</th>
  40. <th>Base-14</th>
  41. <th>AWT/OS</th>
  42. <th>Custom</th>
  43. <th>Custom Embedding</th>
  44. </tr>
  45. <tr>
  46. <td>PDF</td>
  47. <td>yes</td>
  48. <td>no</td>
  49. <td>yes</td>
  50. <td>yes</td>
  51. </tr>
  52. <tr>
  53. <td>PostScript</td>
  54. <td>yes</td>
  55. <td>no</td>
  56. <td>yes</td>
  57. <td>yes</td>
  58. </tr>
  59. <!--tr> NOT AVAILABLE YET!!!
  60. <td>PCL</td>
  61. <td>yes (modified)</td>
  62. <td>no</td>
  63. <td>no</td>
  64. <td>no</td>
  65. </tr-->
  66. <tr>
  67. <td>TXT</td>
  68. <td>yes (used for layout but not for output)</td>
  69. <td>no</td>
  70. <td>yes (used for layout but not for output)</td>
  71. <td>no</td>
  72. </tr>
  73. <tr>
  74. <td>AWT</td>
  75. <td>if available from OS</td>
  76. <td>yes</td>
  77. <td>yes</td>
  78. <td>n/a (display only)</td>
  79. </tr>
  80. <tr>
  81. <td>Print</td>
  82. <td>if available from OS</td>
  83. <td>yes</td>
  84. <td>yes</td>
  85. <td>controlled by OS printer driver</td>
  86. </tr>
  87. <tr>
  88. <td>RTF</td>
  89. <td>n/a (font metrics not needed)</td>
  90. <td>n/a</td>
  91. <td>n/a</td>
  92. <td>n/a</td>
  93. </tr>
  94. <tr>
  95. <td>MIF</td>
  96. <td>n/a (font metrics not needed)</td>
  97. <td>n/a</td>
  98. <td>n/a</td>
  99. <td>n/a</td>
  100. </tr>
  101. <tr>
  102. <td>SVG</td>
  103. <td>if available from OS</td>
  104. <td>yes</td>
  105. <td>no</td>
  106. <td>no</td>
  107. </tr>
  108. <tr>
  109. <td>XML</td>
  110. <td>yes</td>
  111. <td>no</td>
  112. <td>yes</td>
  113. <td>n/a</td>
  114. </tr>
  115. </table>
  116. </section>
  117. <section>
  118. <title>Base-14 Fonts</title>
  119. <p>The Adobe PDF Specification specifies a set of 14 fonts that must be available to every PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), Symbol and ZapfDingbats.</p>
  120. </section>
  121. <section id="awt">
  122. <title>AWT/Operating System Fonts</title>
  123. <p>The AWT family of renderers (AWT, Print, SVG), use the Java AWT libraries for font metric information. Through operating system registration, the AWT libraries know what fonts are available on the system, and the font metrics for each one.</p>
  124. </section>
  125. <section id="custom">
  126. <title>Custom Fonts</title>
  127. <p>Support for custom fonts is added by creating font metric files (written in XML) from the actual font files, and registering them with FOP. Currently only Type 1 and TrueType fonts can be added.
  128. More information about fonts can be found at:</p>
  129. <ul>
  130. <li><a href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</a></li>
  131. <li><a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a></li>
  132. </ul>
  133. <section id="type1-metrics">
  134. <title>Type 1 Font Metrics</title>
  135. <p>FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it.
  136. To use it, run the class org.apache.fop.fonts.apps.PFMReader:</p>
  137. <p>Windows (on JDK 1.4 and later):</p>
  138. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
  139. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  140. <p>Windows (on JDK 1.3.x):</p>
  141. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar;lib\xml-apis.jar;
  142. lib\xercesImpl.jar;lib\xalan.jar;lib\serializer.jar
  143. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  144. <p>Unix (on JDK 1.4 and later):</p>
  145. <source>java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar
  146. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  147. <p>Unix (on JDK 1.3.1):</p>
  148. <source>java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar:lib/xml-apis.jar:
  149. lib/xercesImpl.jar:lib/xalan.jar:lib/serializer.jar
  150. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  151. <p>PFMReader [options]:</p>
  152. <ul>
  153. <li><strong>-fn &lt;fontname&gt;</strong> By default, FOP uses the fontname from the
  154. .pfm file when embedding the font. Use the "-fn" option to override this name with one you have
  155. chosen. This may be useful in some cases to ensure that applications using the output document
  156. (Acrobat Reader for example) use the embedded font instead of a local font with the same
  157. name.</li>
  158. </ul>
  159. <note>The classpath in the above example has been simplified for readability.
  160. You will have to adjust the classpath to the names of the actual JAR files in the lib directory.
  161. xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later.</note>
  162. <note>The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values.
  163. FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file.
  164. The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually.
  165. The constructed values however appear to have no visible influence.</note>
  166. </section>
  167. <section id="truetype-metrics">
  168. <title>TrueType Font Metrics</title>
  169. <p>FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it.
  170. Use it in a similar manner to PFMReader.
  171. For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:</p>
  172. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
  173. org.apache.fop.fonts.apps.TTFReader [options]
  174. C:\myfonts\cmr10.ttf ttfcm.xml</source>
  175. <p>TTFReader [options]:</p>
  176. <ul>
  177. <li><strong>-d &lt;DEBUG | INFO &gt;</strong> Sets the debug level (default is
  178. INFO).</li>
  179. <li><strong>-fn &lt;fontname&gt;</strong> Same as for PFMReader.</li>
  180. <li><strong>-ttcname &lt;fontname&gt;</strong> If you're reading data from a
  181. TrueType Collection (.ttc file) you must specify which font from the collection you will read
  182. metrics from.
  183. If you read from a .ttc file without this option, the fontnames will be listed for you.</li>
  184. <li><strong>-enc ansi</strong> Creates a WinAnsi-encoded font metrics file.
  185. Without this option, a CID-keyed font metrics file is created.
  186. The table below summarizes the differences between these two encoding options as currently
  187. used within FOP.
  188. Please note that this information only applies to TrueType fonts and TrueType collections:</li>
  189. </ul>
  190. <table id="ttf-encoding">
  191. <tr>
  192. <th>Issue</th>
  193. <th>WinAnsi</th>
  194. <th>CID-keyed</th>
  195. </tr>
  196. <tr>
  197. <td>Usable Character Set</td>
  198. <td>Limited to WinAnsi character set, which is roughly equivalent to iso-8889-1.</td>
  199. <td>Limited only by the characters in the font itself.</td>
  200. </tr>
  201. <tr>
  202. <td>Embedding the Font</td>
  203. <td>Optional.</td>
  204. <td>Mandatory. Not embedding the font produces invalid PDF documents.</td>
  205. </tr>
  206. </table>
  207. <warning>
  208. You may experience failures with certain TrueType fonts, especially if they don't contain
  209. the so-called Unicode "cmap" table. TTFReader can currently not deal with font like this.
  210. </warning>
  211. </section>
  212. <section id="truetype-collections-metrics">
  213. <title>TrueType Collections Font Metrics</title>
  214. <p>TrueType collections (.ttc files) contain more than one font.
  215. To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.</p>
  216. <p>To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option).
  217. It will display all of the font names and exit with an Exception.</p>
  218. <p>Here is an example of generating a metrics file for a .ttc file:</p>
  219. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
  220. org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho"
  221. msmincho.ttc msminch.xml</source>
  222. </section>
  223. <section id="register">
  224. <title>Register Fonts with FOP</title>
  225. <p>You must tell FOP how to find and use the font metrics files by registering them in the <a href="configuration.html">FOP Configuration</a>. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:</p>
  226. <source><![CDATA[
  227. <fonts>
  228. <!-- register a particular font -->
  229. <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
  230. embed-url="file:///C:/myfonts/FTL_____.pfb">
  231. <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
  232. </font>
  233. <!-- register all the fonts found in a directory -->
  234. <directory>C:\MyFonts1</directory>
  235. <!-- register all the fonts found in a directory
  236. and all of its sub directories (use with care) -->
  237. <directory recursive="true">C:\MyFonts2</directory>
  238. <!-- automatically detect operating system installed fonts -->
  239. <auto-detect/>
  240. </fonts>]]></source>
  241. <note>
  242. Review the documentation for <a href="configuration.html">FOP Configuration</a> for
  243. instructions on making the FOP configuration available to FOP when it runs. Otherwise,
  244. FOP has no way of finding your custom font information.
  245. </note>
  246. <ul>
  247. <li>
  248. URLs are used to access the font metric and font files.
  249. Relative URLs are resolved relative to the font-base property (or base) if available.
  250. See <a href="configuration.html">FOP: Configuration</a> for more information.
  251. </li>
  252. <li>
  253. If relative URLs are specified, they are evaluated relative to the value of the
  254. "font-base" setting. If there is no "font-base" setting, the fonts are evaluated
  255. relative to the base directory.
  256. </li>
  257. <li>Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.</li>
  258. <li>The font "kerning" attribute is optional.</li>
  259. <li>If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
  260. <li>When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
  261. <li>The fonts "directory" tag can be used to register fonts contained within a single or list of directory paths. The "recursive" attribute can be specified to recursively add fonts from all sub directories.</li>
  262. <li>Fonts registered with "font" tag configurations override fonts found by means of "directory" tag definitions.</li>
  263. <li>Fonts found as a result of a "directory" tag configuration override fonts found as a result of the "auto-detect" tag being specified.</li>
  264. <li>The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.
  265. <ul>
  266. <li>On Unix platforms the autodetect feature looks in java user.home + "/.fonts", "/usr/local/fonts", "/usr/share/fonts" and "/usr/X11R6/lib/X11/fonts" for fonts it is able to use.</li>
  267. <li>On Mac platforms the autodetect feature looks in java user.home + "/Library/Fonts/, "/Library/Fonts/", "/System/Library/Fonts/" and "/Network/Library/Fonts/" for fonts it is able to use.</li>
  268. <li>On Windows platforms the autodetect feature attempts to determine the Windows fonts directory (usually C:\WINDOWS\FONTS) and also the existence of a PSFONTS directory for fonts it is able to use.</li>
  269. </ul>
  270. </li>
  271. </ul>
  272. <!--note>Cocoon users will need to setup the config, see FOPSerializer for more information.</note-->
  273. </section>
  274. <section id="embedding">
  275. <title>Embedding</title>
  276. <note>The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts.</note>
  277. <note>The font is simply embedded into the PDF file, it is not converted.</note>
  278. <p>Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute.
  279. If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.</p>
  280. <warning>
  281. Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid
  282. PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit
  283. the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set.
  284. </warning>
  285. <p>When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font.
  286. This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.</p>
  287. <p>When embedding PostScript fonts, the entire font is always embedded.</p>
  288. <p>When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the
  289. original font, containing only the glyphs used, is embedded in the output document.</p>
  290. </section>
  291. <section id="embedding-base14">
  292. <title>Explicitly embedding the base 14 fonts</title>
  293. <p>
  294. There are cases where you might want to force the embedding of one or more of the base 14 fonts that
  295. can normally be considered available on the target platform (viewer, printer). One of these cases is
  296. PDF/A which mandates the embedding of even the base 14 fonts. Embedding a font such as Helvetica or
  297. Courier is straight-forward. The "Symbol" and "ZapfDingbats" fonts, however, currently present a
  298. problem because FOP cannot correctly determine the encoding of these two single-byte fonts through
  299. the PFM file. FOP now correctly interprets the "encoding" value in the XML font metrics file, but the
  300. PFMReader application writes "UnknownEncoding" to the generated XML file. In order to embed "Symbol"
  301. and "ZapfDingbats" you have to manually change the XML font metrics file and specify "SymbolEncoding"
  302. or "ZapfdingbatsEncoding" encoding respectively as the value for the "encoding" element.
  303. </p>
  304. <p>Example:</p>
  305. <source><![CDATA[
  306. <?xml version="1.0" encoding="UTF-8"?>
  307. <font-metrics type="TYPE1">
  308. <font-name>Symbol</font-name>
  309. <embed/>
  310. <encoding>SymbolEncoding</encoding>
  311. <cap-height>673</cap-height>
  312. <x-height>766</x-height>
  313. [..]]]></source>
  314. </section>
  315. </section>
  316. </body>
  317. </document>