ftautoh.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /***************************************************************************/
  2. /* */
  3. /* ftautoh.h */
  4. /* */
  5. /* FreeType API for controlling the auto-hinter (specification only). */
  6. /* */
  7. /* Copyright 2012, 2013 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #ifndef __FTAUTOH_H__
  18. #define __FTAUTOH_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. #ifdef FREETYPE_H
  22. #error "freetype.h of FreeType 1 has been loaded!"
  23. #error "Please fix the directory search order for header files"
  24. #error "so that freetype.h of FreeType 2 is found first."
  25. #endif
  26. FT_BEGIN_HEADER
  27. /**************************************************************************
  28. *
  29. * @section:
  30. * auto_hinter
  31. *
  32. * @title:
  33. * The auto-hinter
  34. *
  35. * @abstract:
  36. * Controlling the auto-hinting module.
  37. *
  38. * @description:
  39. * While FreeType's auto-hinter doesn't expose API functions by itself,
  40. * it is possible to control its behaviour with @FT_Property_Set and
  41. * @FT_Property_Get. The following lists the available properties
  42. * together with the necessary macros and structures.
  43. *
  44. * Note that the auto-hinter's module name is `autofitter' for
  45. * historical reasons.
  46. *
  47. */
  48. /**************************************************************************
  49. *
  50. * @property:
  51. * glyph-to-script-map
  52. *
  53. * @description:
  54. * *Experimental* *only*
  55. *
  56. * The auto-hinter provides various script modules to hint glyphs.
  57. * Examples of supported scripts are Latin or CJK. Before a glyph is
  58. * auto-hinted, the Unicode character map of the font gets examined, and
  59. * the script is then determined based on Unicode character ranges, see
  60. * below.
  61. *
  62. * OpenType fonts, however, often provide much more glyphs than
  63. * character codes (small caps, superscripts, ligatures, swashes, etc.),
  64. * to be controlled by so-called `features'. Handling OpenType features
  65. * can be quite complicated and thus needs a separate library on top of
  66. * FreeType.
  67. *
  68. * The mapping between glyph indices and scripts (in the auto-hinter
  69. * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an
  70. * array with `num_glyphs' elements, as found in the font's @FT_Face
  71. * structure. The `glyph-to-script-map' property returns a pointer to
  72. * this array, which can be modified as needed. Note that the
  73. * modification should happen before the first glyph gets processed by
  74. * the auto-hinter so that the global analysis of the font shapes
  75. * actually uses the modified mapping.
  76. *
  77. * The following example code demonstrates how to access it (omitting
  78. * the error handling).
  79. *
  80. * {
  81. * FT_Library library;
  82. * FT_Face face;
  83. * FT_Prop_GlyphToScriptMap prop;
  84. *
  85. *
  86. * FT_Init_FreeType( &library );
  87. * FT_New_Face( library, "foo.ttf", 0, &face );
  88. *
  89. * prop.face = face;
  90. *
  91. * FT_Property_Get( library, "autofitter",
  92. * "glyph-to-script-map", &prop );
  93. *
  94. * // adjust `prop.map' as needed right here
  95. *
  96. * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
  97. * }
  98. *
  99. */
  100. /**************************************************************************
  101. *
  102. * @enum:
  103. * FT_AUTOHINTER_SCRIPT_XXX
  104. *
  105. * @description:
  106. * *Experimental* *only*
  107. *
  108. * A list of constants used for the @glyph-to-script-map property to
  109. * specify the script submodule the auto-hinter should use for hinting a
  110. * particular glyph.
  111. *
  112. * @values:
  113. * FT_AUTOHINTER_SCRIPT_NONE ::
  114. * Don't auto-hint this glyph.
  115. *
  116. * FT_AUTOHINTER_SCRIPT_LATIN ::
  117. * Apply the latin auto-hinter. For the auto-hinter, `latin' is a
  118. * very broad term, including Cyrillic and Greek also since characters
  119. * from those scripts share the same design constraints.
  120. *
  121. * By default, characters from the following Unicode ranges are
  122. * assigned to this submodule.
  123. *
  124. * {
  125. * U+0020 - U+007F // Basic Latin (no control characters)
  126. * U+00A0 - U+00FF // Latin-1 Supplement (no control characters)
  127. * U+0100 - U+017F // Latin Extended-A
  128. * U+0180 - U+024F // Latin Extended-B
  129. * U+0250 - U+02AF // IPA Extensions
  130. * U+02B0 - U+02FF // Spacing Modifier Letters
  131. * U+0300 - U+036F // Combining Diacritical Marks
  132. * U+0370 - U+03FF // Greek and Coptic
  133. * U+0400 - U+04FF // Cyrillic
  134. * U+0500 - U+052F // Cyrillic Supplement
  135. * U+1D00 - U+1D7F // Phonetic Extensions
  136. * U+1D80 - U+1DBF // Phonetic Extensions Supplement
  137. * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement
  138. * U+1E00 - U+1EFF // Latin Extended Additional
  139. * U+1F00 - U+1FFF // Greek Extended
  140. * U+2000 - U+206F // General Punctuation
  141. * U+2070 - U+209F // Superscripts and Subscripts
  142. * U+20A0 - U+20CF // Currency Symbols
  143. * U+2150 - U+218F // Number Forms
  144. * U+2460 - U+24FF // Enclosed Alphanumerics
  145. * U+2C60 - U+2C7F // Latin Extended-C
  146. * U+2DE0 - U+2DFF // Cyrillic Extended-A
  147. * U+2E00 - U+2E7F // Supplemental Punctuation
  148. * U+A640 - U+A69F // Cyrillic Extended-B
  149. * U+A720 - U+A7FF // Latin Extended-D
  150. * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures)
  151. * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
  152. * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
  153. * }
  154. *
  155. * FT_AUTOHINTER_SCRIPT_CJK ::
  156. * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
  157. * Vietnamese, and some other scripts.
  158. *
  159. * By default, characters from the following Unicode ranges are
  160. * assigned to this submodule.
  161. *
  162. * {
  163. * U+1100 - U+11FF // Hangul Jamo
  164. * U+2E80 - U+2EFF // CJK Radicals Supplement
  165. * U+2F00 - U+2FDF // Kangxi Radicals
  166. * U+2FF0 - U+2FFF // Ideographic Description Characters
  167. * U+3000 - U+303F // CJK Symbols and Punctuation
  168. * U+3040 - U+309F // Hiragana
  169. * U+30A0 - U+30FF // Katakana
  170. * U+3100 - U+312F // Bopomofo
  171. * U+3130 - U+318F // Hangul Compatibility Jamo
  172. * U+3190 - U+319F // Kanbun
  173. * U+31A0 - U+31BF // Bopomofo Extended
  174. * U+31C0 - U+31EF // CJK Strokes
  175. * U+31F0 - U+31FF // Katakana Phonetic Extensions
  176. * U+3200 - U+32FF // Enclosed CJK Letters and Months
  177. * U+3300 - U+33FF // CJK Compatibility
  178. * U+3400 - U+4DBF // CJK Unified Ideographs Extension A
  179. * U+4DC0 - U+4DFF // Yijing Hexagram Symbols
  180. * U+4E00 - U+9FFF // CJK Unified Ideographs
  181. * U+A960 - U+A97F // Hangul Jamo Extended-A
  182. * U+AC00 - U+D7AF // Hangul Syllables
  183. * U+D7B0 - U+D7FF // Hangul Jamo Extended-B
  184. * U+F900 - U+FAFF // CJK Compatibility Ideographs
  185. * U+FE10 - U+FE1F // Vertical forms
  186. * U+FE30 - U+FE4F // CJK Compatibility Forms
  187. * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms
  188. * U+1B000 - U+1B0FF // Kana Supplement
  189. * U+1D300 - U+1D35F // Tai Xuan Hing Symbols
  190. * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
  191. * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
  192. * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
  193. * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
  194. * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
  195. * }
  196. *
  197. * FT_AUTOHINTER_SCRIPT_INDIC ::
  198. * Apply the indic auto-hinter, covering all major scripts from the
  199. * Indian sub-continent and some other related scripts like Thai, Lao,
  200. * or Tibetan.
  201. *
  202. * By default, characters from the following Unicode ranges are
  203. * assigned to this submodule.
  204. *
  205. * {
  206. * U+0900 - U+0DFF // Indic Range
  207. * U+0F00 - U+0FFF // Tibetan
  208. * U+1900 - U+194F // Limbu
  209. * U+1B80 - U+1BBF // Sundanese
  210. * U+1C80 - U+1CDF // Meetei Mayak
  211. * U+A800 - U+A82F // Syloti Nagri
  212. * U+11800 - U+118DF // Sharada
  213. * }
  214. *
  215. * Note that currently Indic support is rudimentary only, missing blue
  216. * zone support.
  217. *
  218. */
  219. #define FT_AUTOHINTER_SCRIPT_NONE 0
  220. #define FT_AUTOHINTER_SCRIPT_LATIN 1
  221. #define FT_AUTOHINTER_SCRIPT_CJK 2
  222. #define FT_AUTOHINTER_SCRIPT_INDIC 3
  223. /**************************************************************************
  224. *
  225. * @struct:
  226. * FT_Prop_GlyphToScriptMap
  227. *
  228. * @description:
  229. * *Experimental* *only*
  230. *
  231. * The data exchange structure for the @glyph-to-script-map property.
  232. *
  233. */
  234. typedef struct FT_Prop_GlyphToScriptMap_
  235. {
  236. FT_Face face;
  237. FT_Byte* map;
  238. } FT_Prop_GlyphToScriptMap;
  239. /**************************************************************************
  240. *
  241. * @property:
  242. * fallback-script
  243. *
  244. * @description:
  245. * *Experimental* *only*
  246. *
  247. * If no auto-hinter script module can be assigned to a glyph, a
  248. * fallback script gets assigned to it (see also the
  249. * @glyph-to-script-map property). By default, this is
  250. * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property,
  251. * this fallback value can be changed.
  252. *
  253. * {
  254. * FT_Library library;
  255. * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
  256. *
  257. *
  258. * FT_Init_FreeType( &library );
  259. *
  260. * FT_Property_Set( library, "autofitter",
  261. * "fallback-script", &fallback_script );
  262. * }
  263. *
  264. * @note:
  265. * This property can be used with @FT_Property_Get also.
  266. *
  267. * It's important to use the right timing for changing this value: The
  268. * creation of the glyph-to-script map that eventually uses the
  269. * fallback script value gets triggered either by setting or reading a
  270. * face-specific property like @glyph-to-script-map, or by auto-hinting
  271. * any glyph from that face. In particular, if you have already created
  272. * an @FT_Face structure but not loaded any glyph (using the
  273. * auto-hinter), a change of the fallback script will affect this face.
  274. *
  275. */
  276. /**************************************************************************
  277. *
  278. * @property:
  279. * default-script
  280. *
  281. * @description:
  282. * *Experimental* *only*
  283. *
  284. * If Freetype gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
  285. * the HarfBuzz library access OpenType features for getting better
  286. * glyph coverages, this property sets the (auto-fitter) script to be
  287. * used for the default (OpenType) script data of a font's GSUB table.
  288. * Features for the default script are intended for all scripts not
  289. * explicitly handled in GSUB; an example is a `dlig' feature,
  290. * containing the combination of the characters `T', `E', and `L' to
  291. * form a `TEL' ligature.
  292. *
  293. * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the
  294. * `default-script' property, this default value can be changed.
  295. *
  296. * {
  297. * FT_Library library;
  298. * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE;
  299. *
  300. *
  301. * FT_Init_FreeType( &library );
  302. *
  303. * FT_Property_Set( library, "autofitter",
  304. * "default-script", &default_script );
  305. * }
  306. *
  307. * @note:
  308. * This property can be used with @FT_Property_Get also.
  309. *
  310. * It's important to use the right timing for changing this value: The
  311. * creation of the glyph-to-script map that eventually uses the
  312. * default script value gets triggered either by setting or reading a
  313. * face-specific property like @glyph-to-script-map, or by auto-hinting
  314. * any glyph from that face. In particular, if you have already created
  315. * an @FT_Face structure but not loaded any glyph (using the
  316. * auto-hinter), a change of the default script will affect this face.
  317. *
  318. */
  319. /**************************************************************************
  320. *
  321. * @property:
  322. * increase-x-height
  323. *
  324. * @description:
  325. * For ppem values in the range 6~<= ppem <= `increase-x-height', round
  326. * up the font's x~height much more often than normally. If the value
  327. * is set to~0, which is the default, this feature is switched off. Use
  328. * this property to improve the legibility of small font sizes if
  329. * necessary.
  330. *
  331. * {
  332. * FT_Library library;
  333. * FT_Face face;
  334. * FT_Prop_IncreaseXHeight prop;
  335. *
  336. *
  337. * FT_Init_FreeType( &library );
  338. * FT_New_Face( library, "foo.ttf", 0, &face );
  339. * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
  340. *
  341. * prop.face = face;
  342. * prop.limit = 14;
  343. *
  344. * FT_Property_Set( library, "autofitter",
  345. * "increase-x-height", &prop );
  346. * }
  347. *
  348. * @note:
  349. * This property can be used with @FT_Property_Get also.
  350. *
  351. * Set this value right after calling @FT_Set_Char_Size, but before
  352. * loading any glyph (using the auto-hinter).
  353. *
  354. */
  355. /**************************************************************************
  356. *
  357. * @struct:
  358. * FT_Prop_IncreaseXHeight
  359. *
  360. * @description:
  361. * The data exchange structure for the @increase-x-height property.
  362. *
  363. */
  364. typedef struct FT_Prop_IncreaseXHeight_
  365. {
  366. FT_Face face;
  367. FT_UInt limit;
  368. } FT_Prop_IncreaseXHeight;
  369. /* */
  370. FT_END_HEADER
  371. #endif /* __FTAUTOH_H__ */
  372. /* END */