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.

hyphenation.xml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. Copyright 1999-2004 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 V1.1//EN"
  16. "http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/core/context/resources/schema/dtd/document-v12.dtd">
  17. <document>
  18. <header>
  19. <title>FOP: Hyphenation</title>
  20. <version>$Revision$</version>
  21. </header>
  22. <body>
  23. <section id="support">
  24. <title>Hyphenation Support</title>
  25. <section id="intro">
  26. <title>Introduction</title>
  27. <p>FOP uses Liang's hyphenation algorithm, well known from TeX. It needs
  28. language specific pattern and other data for operation.</p>
  29. <p>Because of <link href="#license-issues">licensing issues</link> (and for
  30. convenience), all hyphenation patterns for FOP are made available through
  31. the <fork href="http://offo.sourceforge.net/hyphenation.html">Objects For
  32. Formatting Objects</fork> project.</p>
  33. <note>If you have made improvements to an existing FOP hyphenation pattern,
  34. or if you have created one from scratch, please consider contributing these
  35. to OFFO so that they can benefit other FOP users as well.
  36. Please inquire on the <link href="maillist.html#fop-user">FOP User
  37. mailing list</link>.</note>
  38. </section>
  39. <section id="license-issues">
  40. <title>License Issues</title>
  41. <p>Many of the hyphenation files distributed with TeX and its offspring are
  42. licenced under the <fork href="http://www.latex-project.org/lppl.html">LaTeX
  43. Project Public License (LPPL)</fork>, which prevents them from being
  44. distributed with Apache software. The LPPL puts restrictions on file names
  45. in redistributed derived works which we feel can't guarantee. Some
  46. hyphenation pattern files have other or additional restrictions, for
  47. example against use for commercial purposes.</p>
  48. <p>Although Apache FOP cannot redistribute hyphenation pattern files that do
  49. not conform with its license scheme, that does not necessarily prevent users
  50. from using such hyphenation patterns with FOP. However, it does place on
  51. the user the responsibility for determining whether the user can rightly use
  52. such hyphenation patterns under the hyphenation pattern license.</p>
  53. <warning>The user is responsible to settle license issues for hyphenation
  54. pattern files that are obtained from non-Apache sources.</warning>
  55. </section>
  56. <section id="sources">
  57. <title>Sources of Custom Hyphenation Pattern Files</title>
  58. <p>The most important source of hyphenation pattern files is the
  59. <fork href="http://www.ctan.org/tex-archive/language/hyphenation/">CTAN TeX
  60. Archive</fork>.</p>
  61. </section>
  62. <section id="install">
  63. <title>Installing Custom Hyphenation Patterns</title>
  64. <p>To install custom a custom hyphenation pattern for use with FOP:</p>
  65. <ol>
  66. <li>Convert the TeX hyphenation pattern file to the FOP format. The FOP
  67. format is an xml file conforming to the DTD found at
  68. <code>{fop-dir}/hyph/hyphenation.dtd</code>.</li>
  69. <li>Name this new file following this schema:
  70. <code>languageCode_countryCode.xml</code>. The country code is
  71. optional, and should be used only if needed. For example:
  72. <ul>
  73. <li><code>en_US.xml</code> would be the file name for American
  74. English hyphenation patterns.</li>
  75. <li><code>it.xml</code> would be the file name for Italian
  76. hyphenation patterns.</li>
  77. </ul>
  78. The language and country codes must match the XSL-FO input, which
  79. follows <link href="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">ISO
  80. 639</link> (languages) and <link href="http://www.ics.uci.edu/pub/ietf/http/related/iso3166.txt">ISO
  81. 3166</link> (countries). NOTE: The ISO 639/ISO 3166 convention is that
  82. language names are written in lower case, while country codes are written
  83. in upper case. FOP does not check whether the language and country specified
  84. in the FO source are actually from the current standard, but it relies
  85. on it being two letter strings in a few places. So you can make up your
  86. own codes for custom hyphenation patterns, but they should be two
  87. letter strings too (patches for proper handling extensions are welcome)</li>
  88. <li>There are basically three ways to make the FOP-compatible hyphenation pattern
  89. file(s) accessible to FOP:
  90. <ul>
  91. <li>Download the precompiled JAR from <fork href="http://offo.sourceforge.net/hyphenation.html">OFFO
  92. </fork> and place it either in the <code>{fop-dir}/lib</code> directory, or
  93. in a directory of your choice (and append the full path to the JAR to
  94. the environment variable <code>FOP_HYPHENATION_PATH</code>).</li>
  95. <li>Download the desired FOP-compatible hyphenation pattern file(s) from
  96. <fork href="http://offo.sourceforge.net/hyphenation.html">OFFO</fork>,
  97. <ul>
  98. <li>place them in the directory <code>{fop-dir}/hyph</code>, </li>
  99. <li>or place them in a directory of your choice and set the Ant variable
  100. <code>hyph.dir</code> to point to that directory (in
  101. <code>build-local.properties</code>),</li>
  102. </ul>
  103. and run Ant with build target
  104. <code>hyphenation-jar</code>. This will create a JAR containing the
  105. compiled patterns in <code>{fop-dir}/build</code> that will be added to the
  106. classpath on the next run.
  107. (When FOP is built from scratch, and there are pattern source file(s)
  108. present in <code>{fop-dir}/hyph</code>, this JAR will automatically
  109. be created from the supplied pattern(s)).</li>
  110. <li>Put the pattern source file(s) into a directory of your choice and
  111. configure FOP to look for custom patterns in this directory, by setting the
  112. <link href="configuration.html#hyphenation-dir">&lt;hyphenation-dir&gt;</link>
  113. configuration option.</li>
  114. </ul>
  115. </li>
  116. </ol>
  117. <warning>
  118. Either of these three options will ensure hyphenation is working when using
  119. FOP from the command-line. If FOP is being embedded, remember to add the location(s)
  120. of the hyphenation JAR(s) to the CLASSPATH (option 1 and 2) or to set the
  121. <link href="configuration.html#hyphenation-dir">&lt;hyphenation-dir&gt;</link>
  122. configuration option programmatically (option 3).
  123. </warning>
  124. </section>
  125. </section>
  126. <section id="patterns">
  127. <title>Hyphenation Patterns</title>
  128. <p>If you would like to build your own hyphenation pattern files, or modify
  129. existing ones, this section will help you understand how to do so. Even
  130. when creating a pattern file from scratch, it may be beneficial to start
  131. with an existing file and modify it. See <fork href="http://offo.sourceforge.net/hyphenation.html">
  132. OFFO's Hyphenation page</fork> for examples.
  133. Here is a brief explanation of the contents of FOP's hyphenation patterns:</p>
  134. <warning>The remaining content of this section should be considered "draft"
  135. quality. It was drafted from theoretical literature, and has not been
  136. tested against actual FOP behavior. It may contain errors or omissions.
  137. Do not rely on these instructions without testing everything stated here.
  138. If you use these instructions, please provide feedback on the
  139. <link href="maillist.html#fop-user">FOP User mailing list</link>, either
  140. confirming their accuracy, or raising specific problems that we can
  141. address.</warning>
  142. <ul>
  143. <li>The root of the pattern file is the &lt;hyphenation-info> element.</li>
  144. <li>&lt;hyphen-char>: its attribute "value" contains the character signalling
  145. a hyphen in the &lt;exceptions> section. It has nothing to do with the
  146. hyphenation character used in FOP, use the XSLFO hyphenation-character
  147. property for defining the hyphenation character there. At some points
  148. a dash U+002D is hardwired in the code, so you'd better use this too
  149. (patches to rectify the situation are welcome). There is no default,
  150. if you declare exceptions with hyphenations, you must declare the
  151. hyphen-char too.</li>
  152. <li>&lt;hyphen-min> contains two attributes:
  153. <ul>
  154. <li>before: the minimum number of characters in a word allowed to exist
  155. on a line immediately preceding a hyphenated word-break.</li>
  156. <li>after: the minimum number of characters in a word allowed to exist
  157. on a line immediately after a hyphenated word-break.</li>
  158. </ul>
  159. This element is unused and not even read. It should be considered a
  160. documentation for parameters used during pattern generation.
  161. </li>
  162. <li>&lt;classes> contains whitespace-separated character sets. The members
  163. of each set should be treated as equivalent for purposes of hyphenation,
  164. usually upper and lower case of the same character. The first character
  165. of the set is the canonical character, the patterns and exceptions
  166. should only contain these canonical representation characters (except
  167. digits for weight, the period (.) as word delimiter in the patterns and
  168. the hyphen char in exceptions, of course).</li>
  169. <li>&lt;exceptions> contains whitespace-separated words, each of which
  170. has either explicit hyphen characters to denote acceptable breakage
  171. points, or no hyphen characters, to indicate that this word should
  172. never be hyphenated, or contain explicit &lt;hyp> elements for specifying
  173. changes of spelling due to hyphenation (like backen -> bak-ken or
  174. Stoffarbe -> Stoff-farbe in the old german spelling). Exceptions override
  175. the patterns described below. Explicit &lt;hyp> declarations don't work
  176. yet (patches welcome). Exceptions are generally a bit brittle, test
  177. carefully.</li>
  178. <li>&lt;patterns> includes whitespace-separated patterns, which are what
  179. drive most hyphenation decisions. The characters in these patterns are
  180. explained as follows:
  181. <ul>
  182. <li>non-numeric characters represent characters in a sub-word to be
  183. evaluated</li>
  184. <li>the period character (.) represents a word boundary, i.e. either
  185. the beginning or ending of a word</li>
  186. <li>numeric characters represent a scoring system for indicating the
  187. acceptability of a hyphen in this location. Odd numbers represent an
  188. acceptable location for a hyphen, with higher values overriding lower
  189. inhibiting values. Even numbers indicate an unacceptable location, with
  190. higher values overriding lower values indicating an acceptable position.
  191. A value of zero (inhibiting) is implied when there is no number present.
  192. Generally patterns are constructed so that valuse greater than 4 are rare.
  193. Due to a bug currently patterns with values of 8 and greater don't
  194. have an effect, so don't wonder.</li>
  195. </ul>
  196. Here are some examples from the English patterns file:
  197. <ul>
  198. <li>Knuth (<em>The TeXBook</em>, Appendix H) uses the example <strong>hach4</strong>, which indicates that it is extremely undesirable to place a hyphen after the substring "hach", for example in the word "toothach-es".</li>
  199. <li><strong>.leg5e</strong> indicates that "leg-e", when it occurs at the beginning of a word, is a very good place to place a hyphen, if one is needed. Words like "leg-end" and "leg-er-de-main" fit this pattern.</li>
  200. </ul>
  201. Note that the algorithm that uses this data searches for each of the word's substrings in the patterns, and chooses the <em>highest</em> value found for letter combination.
  202. </li>
  203. </ul>
  204. <p>If you want to convert a TeX hyphenation pattern file, you have to undo
  205. the TeX encoding for non-ASCII text. FOP uses Unicode, and the patterns
  206. must be proper Unicode too. You should be aware of the XML encoding issues,
  207. preferably use a good Unicode editor.</p>
  208. <p>Note that FOP does not do Unicode character normalization. If you use
  209. combining chars for accents and other character decorations, you must
  210. declare character classes for them, and use the same sequence of base character
  211. and combining marks in the XSLFO source, otherwise the pattern wouldn't match.
  212. Fortunately, Unicode provides precomposed characters for all important cases
  213. in common languages, until now nobody run seriously into this issue. Some dead
  214. languages and dialects, especially ancient ones, may pose a real problem
  215. though.</p>
  216. <p>If you want to generate your own patterns, an open-source utility called
  217. patgen is available on many Unix/Linux distributions and every TeX
  218. distribution which can be used to assist in
  219. creating pattern files from dictionaries. Pattern creation for languages like
  220. english or german is an art. If you can, read Frank Liang's original paper
  221. "Word Hy-phen-a-tion by Com-pu-ter" (yes, with hyphens). It is not available
  222. online. The original patgen.web source, included in the TeX source distributions,
  223. contains valuable comments, unfortunately technical details obscure often the
  224. high level issues. Another important source is
  225. <fork href="http://www.ctan.org/tex-archive/systems/knuth/tex/texbook.tex">The
  226. TeX Book</fork>, appendix H (either read the TeX source, or run it through
  227. TeX to typeset it). Secondary articles, for example the works by Petr Sojka,
  228. may alos give some much needed insigth into problems arising in automated
  229. hyphenation.</p>
  230. </section>
  231. </body>
  232. </document>