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 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 V1.1//EN"
  18. "http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/core/context/resources/schema/dtd/document-v12.dtd">
  19. <document>
  20. <header>
  21. <title>FOP: Fonts</title>
  22. <version>$Revision$</version>
  23. <authors>
  24. <person name="Jeremias Märki" email=""/>
  25. <person name="Tore Engvig" email=""/>
  26. </authors>
  27. </header>
  28. <body>
  29. <section id="intro">
  30. <title>Summary</title>
  31. <p>The following table summarizes the font capabilities of the various FOP renderers:</p>
  32. <table>
  33. <tr>
  34. <th>Renderer</th>
  35. <th>Base-14</th>
  36. <th>AWT/OS</th>
  37. <th>Custom</th>
  38. <th>Custom Embedding</th>
  39. </tr>
  40. <tr>
  41. <td>PDF</td>
  42. <td>yes</td>
  43. <td>no</td>
  44. <td>yes</td>
  45. <td>yes</td>
  46. </tr>
  47. <tr>
  48. <td>PostScript</td>
  49. <td>yes</td>
  50. <td>no</td>
  51. <td>yes</td>
  52. <td>no</td>
  53. </tr>
  54. <tr>
  55. <td>PCL</td>
  56. <td>yes (modified)</td>
  57. <td>no</td>
  58. <td>no</td>
  59. <td>no</td>
  60. </tr>
  61. <tr>
  62. <td>TXT</td>
  63. <td>yes (used for layout but not for output)</td>
  64. <td>no</td>
  65. <td>yes (used for layout but not for output)</td>
  66. <td>no</td>
  67. </tr>
  68. <tr>
  69. <td>AWT</td>
  70. <td>if available from OS</td>
  71. <td>yes</td>
  72. <td>yes</td>
  73. <td>n/a (display only)</td>
  74. </tr>
  75. <tr>
  76. <td>Print</td>
  77. <td>if available from OS</td>
  78. <td>yes</td>
  79. <td>yes</td>
  80. <td>controlled by OS printer driver</td>
  81. </tr>
  82. <tr>
  83. <td>RTF</td>
  84. <td>n/a (font metrics not needed)</td>
  85. <td>n/a</td>
  86. <td>n/a</td>
  87. <td>n/a</td>
  88. </tr>
  89. <tr>
  90. <td>MIF</td>
  91. <td>n/a (font metrics not needed)</td>
  92. <td>n/a</td>
  93. <td>n/a</td>
  94. <td>n/a</td>
  95. </tr>
  96. <tr>
  97. <td>SVG</td>
  98. <td>if available from OS</td>
  99. <td>yes</td>
  100. <td>no</td>
  101. <td>no</td>
  102. </tr>
  103. <tr>
  104. <td>XML</td>
  105. <td>yes</td>
  106. <td>no</td>
  107. <td>yes</td>
  108. <td>n/a</td>
  109. </tr>
  110. </table>
  111. </section>
  112. <section>
  113. <title>Base-14 Fonts</title>
  114. <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>
  115. </section>
  116. <section id="awt">
  117. <title>AWT/Operating System Fonts</title>
  118. <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>
  119. </section>
  120. <section id="custom">
  121. <title>Custom Fonts</title>
  122. <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.
  123. More information about fonts can be found at:</p>
  124. <ul>
  125. <li><link href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</link></li>
  126. <li><link href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</link>
  127. </li>
  128. </ul>
  129. <section id="type1-metrics">
  130. <title>Type 1 Font Metrics</title>
  131. <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.
  132. To use it, run the class org.apache.fop.fonts.apps.PFMReader:</p>
  133. <p>Windows:</p>
  134. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\xml-apis.jar;
  135. lib\xercesImpl.jar;lib\xalan.jar
  136. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  137. <p>Unix:</p>
  138. <source>java -cp build/fop.jar:lib/avalon-framework.jar:lib/xml-apis.jar:
  139. lib/xercesImpl.jar:lib/xalan.jar
  140. org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file</source>
  141. <p>PFMReader [options]:</p>
  142. <ul>
  143. <li><strong>-fn &lt;fontname&gt;</strong> By default, FOP uses the fontname from the
  144. .pfm file when embedding the font. Use the "-fn" option to override this name with one you have
  145. chosen. This may be useful in some cases to ensure that applications using the output document
  146. (Acrobat Reader for example) use the embedded font instead of a local font with the same
  147. name.</li>
  148. </ul>
  149. <note>The classpath in the above example has been simplified for readability.
  150. You will have to adjust the classpath to the names of the actual JAR files in the lib directory.
  151. avalon-framework.jar is necessary only for versions 0.20.5 or later.
  152. xml-apis.jar, xercesImpl.jar and xalan.jar are not necessary for JDK version 1.4 or later.</note>
  153. <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.
  154. FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file.
  155. 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.
  156. The constructed values however appear to have no visible influence.</note>
  157. </section>
  158. <section id="truetype-metrics">
  159. <title>TrueType Font Metrics</title>
  160. <p>FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it.
  161. Use it in a similar manner to PFMReader.
  162. For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:</p>
  163. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\xml-apis.jar;
  164. lib\xercesImpl.jar;lib\xalan.jar
  165. org.apache.fop.fonts.apps.TTFReader [options]
  166. C:\myfonts\cmr10.ttf ttfcm.xml</source>
  167. <p>TTFReader [options]:</p>
  168. <ul>
  169. <li><strong>-d &lt;DEBUG | INFO &gt;</strong> Sets the debug level (default is
  170. INFO).</li>
  171. <li><strong>-fn &lt;fontname&gt;</strong> Same as for PFMReader.</li>
  172. <li><strong>-ttcname &lt;fontname&gt;</strong> If you're reading data from a
  173. TrueType Collection (.ttc file) you must specify which font from the collection you will read
  174. metrics from.
  175. If you read from a .ttc file without this option, the fontnames will be listed for you.</li>
  176. <li><strong>-enc ansi</strong> Creates a WinAnsi-encoded font metrics file.
  177. Without this option, a CID-keyed font metrics file is created.
  178. The table below summarizes the differences between these two encoding options as currently
  179. used within FOP.
  180. Please note that this information only applies to TrueType fonts and TrueType collections:</li>
  181. </ul>
  182. <table id="ttf-encoding">
  183. <tr>
  184. <th>Issue</th>
  185. <th>WinAnsi</th>
  186. <th>CID-keyed</th>
  187. </tr>
  188. <tr>
  189. <td>Usable Character Set</td>
  190. <td>Limited to WinAnsi character set, which is roughly equivalent to iso-8889-1.</td>
  191. <td>Limited only by the characters in the font itself.</td>
  192. </tr>
  193. <tr>
  194. <td>Character Encoding in the Output Document.</td>
  195. <td>Correct.</td>
  196. <td>Never correct. Search, index, and cut-and-paste operations in the output document
  197. will produce incorrect results.</td>
  198. </tr>
  199. <tr>
  200. <td>Character Display</td>
  201. <td>Correct.</td>
  202. <td>Correct if and only if the font is embedded in the output. (This is possible
  203. because, although the underlying characters are encoded incorrectly, the embedded font is
  204. also encoded incorrectly).</td>
  205. </tr>
  206. </table>
  207. <warning id="cid-keyed-encoding-ttf">As shown in the above table, regardless of
  208. whether the font is embedded or not, text generated from a CID-keyed font metrics file
  209. will <em>never </em>be encoded properly.
  210. Further, if the related font is not embedded, it cannot even be displayed properly.
  211. Obviously, this behavior is not desirable, and we hope to correct it in upcoming releases.</warning>
  212. </section>
  213. <section id="truetype-collections-metrics">
  214. <title>TrueType Collections Font Metrics</title>
  215. <p>TrueType collections (.ttc files) contain more than one font.
  216. 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>
  217. <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).
  218. It will display all of the font names and exit with an Exception.</p>
  219. <p>Here is an example of generating a metrics file for a .ttc file:</p>
  220. <source>java -cp build\fop.jar;lib\avalon-framework.jar;lib\xml-apis.jar;
  221. lib\xercesImpl.jar;lib\xalan.jar
  222. org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho"
  223. msmincho.ttc msminch.xml</source>
  224. </section>
  225. <section id="register">
  226. <title>Register Fonts with FOP</title>
  227. <p>You must tell FOP how to find and use the font metrics files by registering them in the <link href="configuration.html">FOP Configuration</link>. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:</p>
  228. <source><![CDATA[<font metrics-file="FTL_____.xml" kerning="yes"
  229. embed-file="C:\myfonts\FTL_____.pfb">
  230. <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
  231. </font>]]></source>
  232. <note>Review the documentation for <link href="configuration.html">FOP Configuration</link> for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information.</note>
  233. <ul>
  234. <li>Starting with FOP version 0.20.5 you can use URLs for the paths to the font files.
  235. Relative URLs are resolved relative to the fontBaseDir property (or baseDir) if available. See <link href="configuration.html">FOP: Configuration</link> for more information.</li>
  236. <li>The "kerning" and "embed-file" attributes are optional. Kerning is currently not used at all. 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>
  237. <li>When setting the embed-file 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>
  238. </ul>
  239. <note>Cocoon users will need to setup the config, see FOPSerializer for more information.</note>
  240. </section>
  241. <section id="embedding">
  242. <title>Embedding</title>
  243. <note>The PostScript renderer does not yet support font embedding.</note>
  244. <note>The font is simply embedded into the PDF file, it is not converted.</note>
  245. <p>Font embedding is enabled in the userconfig.xml file and controlled by the embed-file attribute.
  246. If you don't specify the embed-file attribute the font will not be embedded, but will only be referenced.</p>
  247. <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.
  248. This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.</p>
  249. <p>When embedding PostScript fonts, the entire font is always embedded.</p>
  250. <p>When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the original font, containing only the glyphs used, is embedded in the output document.
  251. Currently, this embedded font contains only the minimum data needed to be embedded in a pdf document, and does not contain any codepage information.
  252. The PDF document contains indexes to the glyphs in the font instead of to encoded characters.
  253. While the document will be displayed correctly, the net effect of this is that searching, indexing, and cut-and-paste will not work properly.</p>
  254. <p>One workaround for this behavior is to use the "-enc ansi" option when generating metrics with TTFReader.
  255. This will cause the whole font to be embedded in the pdf document.
  256. Characters will be WinAnsi encoded (as specified in the PDF spec), so you lose the ability to use characters from other character sets.
  257. See <link href="#ttf-encoding">Table of TTF Encoding Options</link> for more details.</p>
  258. </section>
  259. </section>
  260. </body>
  261. </document>