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

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