Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE fo:root [
  3. <!ENTITY nbsp "&#160;">
  4. ]>
  5. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  6. <fo:layout-master-set>
  7. <fo:simple-page-master master-name="A4"
  8. page-width="21cm"
  9. page-height="29.7cm" >
  10. <fo:region-body
  11. margin-bottom="1.5cm"
  12. margin-right="2cm"
  13. margin-left="2cm"
  14. margin-top="1.5cm"/>
  15. </fo:simple-page-master>
  16. </fo:layout-master-set>
  17. <fo:bookmark-tree>
  18. <fo:bookmark internal-destination="sec0">
  19. <fo:bookmark-title>Adding Fonts to FOP</fo:bookmark-title>
  20. </fo:bookmark>
  21. <fo:bookmark internal-destination="sec1">
  22. <fo:bookmark-title>Adding additional Type 1 fonts</fo:bookmark-title>
  23. <fo:bookmark internal-destination="sec1-1">
  24. <fo:bookmark-title>Generating a font metrics file</fo:bookmark-title>
  25. </fo:bookmark>
  26. <fo:bookmark internal-destination="sec1-2">
  27. <fo:bookmark-title>Register the fonts within FOP</fo:bookmark-title>
  28. </fo:bookmark>
  29. </fo:bookmark>
  30. <fo:bookmark internal-destination="sec2">
  31. <fo:bookmark-title>Adding additional TrueType fonts</fo:bookmark-title>
  32. <fo:bookmark internal-destination="sec2-1">
  33. <fo:bookmark-title>Generating a font metrics file</fo:bookmark-title>
  34. </fo:bookmark>
  35. <fo:bookmark internal-destination="sec2-2">
  36. <fo:bookmark-title>TrueType collections</fo:bookmark-title>
  37. </fo:bookmark>
  38. <fo:bookmark internal-destination="sec2-3">
  39. <fo:bookmark-title>Register the fonts within FOP</fo:bookmark-title>
  40. </fo:bookmark>
  41. </fo:bookmark>
  42. <fo:bookmark internal-destination="sec3">
  43. <fo:bookmark-title>Embedding fonts in the PDF</fo:bookmark-title>
  44. </fo:bookmark>
  45. <fo:bookmark internal-destination="sec4">
  46. <fo:bookmark-title>Example embedding MSGothic</fo:bookmark-title>
  47. <fo:bookmark internal-destination="sec4-1">
  48. <fo:bookmark-title>Setup CLASSPATH</fo:bookmark-title>
  49. </fo:bookmark>
  50. <fo:bookmark internal-destination="sec4-2">
  51. <fo:bookmark-title>Create the metrics file</fo:bookmark-title>
  52. </fo:bookmark>
  53. <fo:bookmark internal-destination="sec4-3">
  54. <fo:bookmark-title>Edit msgothic.xml</fo:bookmark-title>
  55. </fo:bookmark>
  56. <fo:bookmark internal-destination="sec4-4">
  57. <fo:bookmark-title>Register the font with FOP</fo:bookmark-title>
  58. </fo:bookmark>
  59. </fo:bookmark>
  60. <fo:bookmark internal-destination="sec5">
  61. <fo:bookmark-title>Japanese Examples</fo:bookmark-title>
  62. </fo:bookmark>
  63. </fo:bookmark-tree>
  64. <fo:page-sequence master-reference="A4">
  65. <fo:flow flow-name="xsl-region-body">
  66. <fo:wrapper font-family="Times" font-size="12pt" text-align="justify">
  67. <fo:block id="sec0"
  68. text-align="center"
  69. font-family="Helvetica"
  70. font-weight="bold"
  71. font-size="18pt"
  72. color="#0050B2" space-after.optimum="6pt">
  73. Adding Fonts to FOP
  74. </fo:block>
  75. <fo:block space-after.optimum="6pt">
  76. When building PDF files, FOP normally supports only the base 14 font
  77. package defined in the Adobe PDF specification. That includes the
  78. following fonts: Helvetica, Times, Courier, Symbol and ZapfDingbats.
  79. </fo:block>
  80. <fo:block space-after.optimum="6pt">
  81. Font support in FOP can be extended by the addition of font metric
  82. files (written in XML) created from Adobe Type 1 fonts and Truetype
  83. fonts. No other font types (Type 3, etc.) are supported at this time.
  84. </fo:block>
  85. <fo:block id="sec1"
  86. font-family="Helvetica"
  87. font-weight="bold"
  88. font-size="14pt"
  89. color="#0050B2"
  90. space-after.optimum="6pt"
  91. space-before.optimum="12pt">
  92. Adding additional Type 1 fonts
  93. </fo:block>
  94. <fo:block space-after.optimum="6pt" >
  95. As mentioned above you need an XML file containing font metrics to
  96. be able to use an additional font. FOP contains a tool that can generate
  97. such a font metrics file from a PFM file, which normally comes with the
  98. font file.
  99. </fo:block>
  100. <fo:block id="sec1-1"
  101. font-family="Helvetica"
  102. font-weight="bold"
  103. space-after.optimum="6pt"
  104. space-before.optimum="12pt" >
  105. Generating a font metrics file
  106. </fo:block>
  107. <fo:block space-after.optimum="6pt" >
  108. Run the class <fo:inline font-family="Courier">org.apache.fop.fonts.apps.PFMReader</fo:inline>
  109. to generate the XML file.
  110. <fo:block font-family="Courier" font-size="10pt"
  111. space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
  112. java org.apache.fop.fonts.apps.PFMReader pfm-file xml-file
  113. </fo:block>
  114. </fo:block>
  115. <fo:block space-after.optimum="6pt" margin-left="6pt">
  116. Note: The tool will construct some values (FontBBox, StemV and ItalicAngle) based
  117. on assumptions and calculations which are only an approximation to the real values.
  118. FontBBox and Italic Angle can be found in the human-readable part of the PFB file.
  119. The PFMReader tool does not yet interpret PFB files, so if you want to be correct,
  120. you may have to adjust the values in the XML file manually. The constructed values
  121. however appear to have no visible influence.
  122. </fo:block>
  123. <fo:block id="sec1-2"
  124. font-family="Helvetica"
  125. font-weight="bold"
  126. space-after.optimum="6pt"
  127. space-before.optimum="12pt" >
  128. Register the fonts within FOP
  129. </fo:block>
  130. <fo:block space-after.optimum="6pt">
  131. Edit conf/userconfig.xml and add entries for the font if the fonts section, ie:
  132. <fo:block font-family="Courier" font-size="10pt"
  133. space-before.optimum="6pt"
  134. white-space-collapse="false" margin-left="6pt" text-align="start">
  135. <![CDATA[
  136. <font metrics-file="cyberbit.xml" kerning="yes" embed-file="C:\WINNT\Fonts\Cyberbit.ttf">
  137. <font-triplet name="Cyberbit" style="normal" weight="normal">
  138. </font>]]></fo:block>
  139. </fo:block>
  140. <fo:block id="sec2"
  141. font-family="Helvetica"
  142. font-weight="bold"
  143. font-size="14pt"
  144. color="#0050B2"
  145. space-after.optimum="6pt"
  146. space-before.optimum="12pt">
  147. Adding additional TrueType fonts
  148. </fo:block>
  149. <fo:block space-after.optimum="6pt">
  150. Adding Truetype fonts is almost identical to the process of adding type 1 fonts.
  151. The main difference is in the first step.
  152. </fo:block>
  153. <fo:block id="sec2-1"
  154. font-family="Helvetica"
  155. font-weight="bold"
  156. space-after.optimum="6pt"
  157. space-before.optimum="12pt" >
  158. Generating a font metrics file
  159. </fo:block>
  160. <fo:block space-after.optimum="6pt">
  161. As mentioned above you need an XML file containing font metrics to be able to use
  162. an additional font. FOP contains a tool that can generate such a font metrics file
  163. from your truetype font file.
  164. </fo:block>
  165. <fo:block space-after.optimum="6pt">
  166. Create metrics for the fontfile. We'll use MS Gothic as an example:
  167. <fo:block font-family="Courier" font-size="10pt"
  168. space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
  169. java org.apache.fop.fonts.apps.TTFReader C:\WINNT\Fonts\msgothic.ttf msgothic.xml
  170. </fo:block>
  171. </fo:block>
  172. <fo:block id="sec2-2"
  173. font-family="Helvetica"
  174. font-weight="bold"
  175. space-after.optimum="6pt"
  176. space-before.optimum="12pt" >
  177. TrueType collections
  178. </fo:block>
  179. <fo:block space-after.optimum="6pt">
  180. TrueType collections (.ttc files) contains more than one font. To create metrics
  181. for a ttc file you must specify the font in the collection with the -ttcname
  182. option to TTFReader.
  183. </fo:block>
  184. <fo:block space-after.optimum="6pt">
  185. To get a list of the fonts in a collection, just start the TTFReader as if it
  186. were a normal truetype file (without the -ttcname option). It will then display
  187. all the font names and exit with an Exception.
  188. </fo:block>
  189. <fo:block space-after.optimum="6pt">
  190. Example on generating metrics for a .ttc file:
  191. <fo:block font-family="Courier" font-size="10pt"
  192. space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
  193. java org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" msmincho.ttc msminch.xml
  194. </fo:block>
  195. </fo:block>
  196. <fo:block id="sec2-3"
  197. font-family="Helvetica"
  198. font-weight="bold"
  199. space-after.optimum="6pt"
  200. space-before.optimum="12pt" >
  201. Register the fonts within FOP
  202. </fo:block>
  203. <fo:block space-after.optimum="6pt">
  204. Same as for <fo:basic-link internal-destination="sec1-2" color="blue">
  205. <fo:inline text-decoration="underline">Type&nbsp;1&nbsp;fonts</fo:inline></fo:basic-link>.
  206. </fo:block>
  207. <fo:block id="sec3"
  208. font-family="Helvetica"
  209. font-weight="bold"
  210. font-size="14pt"
  211. color="#0050B2"
  212. space-after.optimum="6pt"
  213. space-before.optimum="12pt">
  214. Embedding fonts
  215. </fo:block>
  216. <fo:block space-after.optimum="6pt">
  217. Font embedding is enabled in the userconfig.xml file. Start Fop with -c userconfig.xml
  218. </fo:block>
  219. <fo:block id="sec4"
  220. font-family="Helvetica"
  221. font-weight="bold"
  222. font-size="14pt"
  223. color="#0050B2"
  224. space-after.optimum="6pt"
  225. space-before.optimum="12pt">
  226. Example embedding MSGothic
  227. </fo:block>
  228. <fo:block space-after.optimum="6pt">
  229. This example will use the Microsoft Gothic TrueType font. This is the font used to render this examples
  230. given in the last section of this file. If you don't have it installed,
  231. you can download an installer at <fo:basic-link color="blue"
  232. external-destination="ftp://ftp.cc.monash.edu.au/pub/nihongo/ie3lpkja.exe">
  233. <fo:inline text-decoration="underline">ftp://ftp.cc.monash.edu.au/pub/nihongo/ie3lpkja.exe</fo:inline>
  234. </fo:basic-link>.
  235. </fo:block>
  236. <fo:block id="sec4-1"
  237. font-family="Helvetica"
  238. font-weight="bold"
  239. space-after.optimum="6pt"
  240. space-before.optimum="12pt">
  241. Setup your classpath to run FOP:
  242. </fo:block>
  243. <fo:block font-family="Courier" font-size="10pt"
  244. space-before.optimum="6pt"
  245. white-space-collapse="false" margin-left="6pt" text-align="start">
  246. C:\Fop-0.18.1> set CLASSPATH=fop.jar;lib\xerces-1.2.3.jar;lib\xalan-2.0.0.jar;lib\batik.jar
  247. </fo:block>
  248. <fo:block id="sec4-2"
  249. font-family="Helvetica"
  250. font-weight="bold"
  251. space-after.optimum="6pt"
  252. space-before.optimum="12pt">
  253. Create the metrics file:
  254. </fo:block>
  255. <fo:block font-family="Courier" font-size="10pt"
  256. space-before.optimum="6pt"
  257. white-space-collapse="false" margin-left="6pt" text-align="start">
  258. C:\Fop-0.18.1> java org.apache.fop.fonts.apps.TTFReader c:\WINNT\Fonts\msgothic.ttf msgothic.xml
  259. TTF Reader v1.1.1
  260. Reading /home/camk/cjkv/msgothic.ttf...
  261. Number of glyphs in font: 13104
  262. Postscript format 3
  263. Creating xml font file...
  264. Creating CID encoded metrics
  265. Writing xml font file msgothic.xml...
  266. This font contains no embedding license restrictions
  267. </fo:block>
  268. <fo:block id="sec4-3"
  269. font-family="Helvetica"
  270. font-weight="bold"
  271. space-after.optimum="6pt"
  272. space-before.optimum="12pt">
  273. Edit the msgothic.xml file and set the <fo:inline font-family="Courier">font-name</fo:inline>
  274. to "MSGothic".
  275. </fo:block>
  276. <fo:block id="sec4-4"
  277. font-family="Helvetica"
  278. font-weight="bold"
  279. space-after.optimum="6pt"
  280. space-before.optimum="12pt">
  281. Edit conf/userconfig.xml and add the following to the &lt;fonts&gt; section:
  282. </fo:block>
  283. <fo:block font-family="Courier" font-size="10pt"
  284. space-before.optimum="6pt"
  285. white-space-collapse="false" margin-left="6pt" text-align="start">
  286. <![CDATA[
  287. <font metrics-file="msgothic.xml" kerning="yes"
  288. embed-file="C:\WINNT\Fonts\msgothic.ttf">
  289. <font-triplet name="MSGothic" style="normal" weight="normal"/>
  290. </font>
  291. ]]>
  292. </fo:block>
  293. <fo:block space-after.optimum="6pt">
  294. Now you can use MSGothic in your .fo files by setting font-family="MSGothic". You'll need to
  295. start FOP specifying the config file as in this example:
  296. <fo:block font-family="Courier" font-size="10pt"
  297. space-before.optimum="6pt"
  298. white-space-collapse="false" margin-left="6pt" text-align="start"
  299. >java -jar fop.jar -c conf/userconfig.xml -fo myfo.fo -pdf mypdf.pdf</fo:block>
  300. </fo:block>
  301. <fo:block id="sec5"
  302. font-family="Helvetica"
  303. font-weight="bold"
  304. font-size="14pt"
  305. color="#0050B2"
  306. space-after.optimum="6pt"
  307. space-before.optimum="12pt">
  308. Examples from <fo:basic-link color="blue" external-destination="http://www.csse.monash.edu.au/~jwb/j_jmdict.html">
  309. <fo:inline text-decoration="underline">JMDict</fo:inline></fo:basic-link> Japanese glossary:
  310. </fo:block>
  311. </fo:wrapper>
  312. <fo:table>
  313. <fo:table-column column-width="50mm"/>
  314. <fo:table-column column-width="50mm"/>
  315. <fo:table-column column-width="50mm"/>
  316. <fo:table-header>
  317. <fo:table-row>
  318. <fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">Japanese (kanji or kanadzukai)</fo:block></fo:table-cell>
  319. <fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">English</fo:block></fo:table-cell>
  320. <fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">German</fo:block></fo:table-cell>
  321. </fo:table-row>
  322. </fo:table-header>
  323. <fo:table-body>
  324. <fo:table-row>
  325. <fo:table-cell ><fo:block font-family="MSGothic">うん</fo:block></fo:table-cell>
  326. <fo:table-cell ><fo:block>"yeah" or "uh huh"</fo:block></fo:table-cell>
  327. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  328. </fo:table-row>
  329. <fo:table-row>
  330. <fo:table-cell ><fo:block font-family="MSGothic">アウタースペース</fo:block></fo:table-cell>
  331. <fo:table-cell ><fo:block>outer space</fo:block></fo:table-cell>
  332. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  333. </fo:table-row>
  334. <fo:table-row>
  335. <fo:table-cell ><fo:block font-family="MSGothic">スペースクラフト</fo:block></fo:table-cell>
  336. <fo:table-cell ><fo:block>spacecraft</fo:block></fo:table-cell>
  337. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  338. </fo:table-row>
  339. <fo:table-row>
  340. <fo:table-cell ><fo:block font-family="MSGothic">スペースシャトル</fo:block></fo:table-cell>
  341. <fo:table-cell ><fo:block>space shuttle</fo:block></fo:table-cell>
  342. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  343. </fo:table-row>
  344. <fo:table-row>
  345. <fo:table-cell ><fo:block font-family="MSGothic">著わす</fo:block></fo:table-cell>
  346. <fo:table-cell ><fo:block>"to write", "to publish"</fo:block></fo:table-cell>
  347. <fo:table-cell ><fo:block>veröffentlichen</fo:block></fo:table-cell>
  348. </fo:table-row>
  349. <fo:table-row>
  350. <fo:table-cell ><fo:block font-family="MSGothic">電子出版</fo:block></fo:table-cell>
  351. <fo:table-cell ><fo:block>electronic publishing</fo:block></fo:table-cell>
  352. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  353. </fo:table-row>
  354. <fo:table-row>
  355. <fo:table-cell ><fo:block font-family="MSGothic">五輪</fo:block></fo:table-cell>
  356. <fo:table-cell ><fo:block>the Olympics</fo:block></fo:table-cell>
  357. <fo:table-cell ><fo:block>Olympische Spiele</fo:block></fo:table-cell>
  358. </fo:table-row>
  359. <fo:table-row>
  360. <fo:table-cell ><fo:block font-family="MSGothic">空港</fo:block></fo:table-cell>
  361. <fo:table-cell ><fo:block>airport</fo:block></fo:table-cell>
  362. <fo:table-cell ><fo:block>Flughafen</fo:block></fo:table-cell>
  363. </fo:table-row>
  364. <fo:table-row>
  365. <fo:table-cell ><fo:block font-family="MSGothic">チューリッヒ</fo:block></fo:table-cell>
  366. <fo:table-cell ><fo:block>Zurich</fo:block></fo:table-cell>
  367. <fo:table-cell ><fo:block>Z&#252;rich</fo:block></fo:table-cell>
  368. </fo:table-row>
  369. <fo:table-row>
  370. <fo:table-cell ><fo:block font-family="MSGothic">コロラド</fo:block></fo:table-cell>
  371. <fo:table-cell ><fo:block>Colorado</fo:block></fo:table-cell>
  372. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  373. </fo:table-row>
  374. <fo:table-row>
  375. <fo:table-cell ><fo:block font-family="MSGothic">コロラドスプリングス</fo:block></fo:table-cell>
  376. <fo:table-cell ><fo:block>Colorado Springs</fo:block></fo:table-cell>
  377. <fo:table-cell ><fo:block></fo:block></fo:table-cell>
  378. </fo:table-row>
  379. </fo:table-body>
  380. </fo:table>
  381. </fo:flow>
  382. </fo:page-sequence>
  383. </fo:root>