ftttdrv.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /***************************************************************************/
  2. /* */
  3. /* ftttdrv.h */
  4. /* */
  5. /* FreeType API for controlling the TrueType driver */
  6. /* (specification only). */
  7. /* */
  8. /* Copyright 2013-2015 by */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. #ifndef __FTTTDRV_H__
  19. #define __FTTTDRV_H__
  20. #include <ft2build.h>
  21. #include FT_FREETYPE_H
  22. #ifdef FREETYPE_H
  23. #error "freetype.h of FreeType 1 has been loaded!"
  24. #error "Please fix the directory search order for header files"
  25. #error "so that freetype.h of FreeType 2 is found first."
  26. #endif
  27. FT_BEGIN_HEADER
  28. /**************************************************************************
  29. *
  30. * @section:
  31. * tt_driver
  32. *
  33. * @title:
  34. * The TrueType driver
  35. *
  36. * @abstract:
  37. * Controlling the TrueType driver module.
  38. *
  39. * @description:
  40. * While FreeType's TrueType driver doesn't expose API functions by
  41. * itself, it is possible to control its behaviour with @FT_Property_Set
  42. * and @FT_Property_Get. The following lists the available properties
  43. * together with the necessary macros and structures.
  44. *
  45. * The TrueType driver's module name is `truetype'.
  46. *
  47. */
  48. /**************************************************************************
  49. *
  50. * @property:
  51. * interpreter-version
  52. *
  53. * @description:
  54. * Currently, two versions are available, representing the bytecode
  55. * interpreter with and without subpixel hinting support,
  56. * respectively. The default is subpixel support if
  57. * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel
  58. * support otherwise (since it isn't available then).
  59. *
  60. * If subpixel hinting is on, many TrueType bytecode instructions behave
  61. * differently compared to B/W or grayscale rendering (except if `native
  62. * ClearType' is selected by the font). The main idea is to render at a
  63. * much increased horizontal resolution, then sampling down the created
  64. * output to subpixel precision. However, many older fonts are not
  65. * suited to this and must be specially taken care of by applying
  66. * (hardcoded) font-specific tweaks.
  67. *
  68. * Details on subpixel hinting and some of the necessary tweaks can be
  69. * found in Greg Hitchcock's whitepaper at
  70. * `http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
  71. *
  72. * The following example code demonstrates how to activate subpixel
  73. * hinting (omitting the error handling).
  74. *
  75. * {
  76. * FT_Library library;
  77. * FT_Face face;
  78. * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38;
  79. *
  80. *
  81. * FT_Init_FreeType( &library );
  82. *
  83. * FT_Property_Set( library, "truetype",
  84. * "interpreter-version",
  85. * &interpreter_version );
  86. * }
  87. *
  88. * @note:
  89. * This property can be used with @FT_Property_Get also.
  90. *
  91. */
  92. /**************************************************************************
  93. *
  94. * @enum:
  95. * TT_INTERPRETER_VERSION_XXX
  96. *
  97. * @description:
  98. * A list of constants used for the @interpreter-version property to
  99. * select the hinting engine for Truetype fonts.
  100. *
  101. * The numeric value in the constant names represents the version
  102. * number as returned by the `GETINFO' bytecode instruction.
  103. *
  104. * @values:
  105. * TT_INTERPRETER_VERSION_35 ::
  106. * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in
  107. * Windows~98; only grayscale and B/W rasterizing is supported.
  108. *
  109. * TT_INTERPRETER_VERSION_38 ::
  110. * Version~38 corresponds to MS rasterizer v.1.9; it is roughly
  111. * equivalent to the hinting provided by DirectWrite ClearType (as
  112. * can be found, for example, in the Internet Explorer~9 running on
  113. * Windows~7).
  114. *
  115. * @note:
  116. * This property controls the behaviour of the bytecode interpreter
  117. * and thus how outlines get hinted. It does *not* control how glyph
  118. * get rasterized! In particular, it does not control subpixel color
  119. * filtering.
  120. *
  121. * If FreeType has not been compiled with configuration option
  122. * FT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 causes an
  123. * `FT_Err_Unimplemented_Feature' error.
  124. *
  125. * Depending on the graphics framework, Microsoft uses different
  126. * bytecode and rendering engines. As a consequence, the version
  127. * numbers returned by a call to the `GETINFO' bytecode instruction are
  128. * more convoluted than desired.
  129. *
  130. * Here are two tables that try to shed some light on the possible
  131. * values for the MS rasterizer engine, together with the additional
  132. * features introduced by it.
  133. *
  134. * {
  135. * GETINFO framework version feature
  136. * -------------------------------------------------------------------
  137. * 3 GDI (Win 3.1), v1.0 16-bit, first version
  138. * TrueImage
  139. * 33 GDI (Win NT 3.1), v1.5 32-bit
  140. * HP Laserjet
  141. * 34 GDI (Win 95) v1.6 font smoothing,
  142. * new SCANTYPE opcode
  143. * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET
  144. * bits in composite glyphs
  145. * 36 MGDI (Win CE 2) v1.6+ classic ClearType
  146. * 37 GDI (XP and later), v1.8 ClearType
  147. * GDI+ old (before Vista)
  148. * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType,
  149. * WPF Y-direction ClearType,
  150. * additional error checking
  151. * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags
  152. * in GETINFO opcode,
  153. * bug fixes
  154. * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag
  155. * DWrite (Win 8) in GETINFO opcode,
  156. * Gray ClearType
  157. * }
  158. *
  159. * The `version' field gives a rough orientation only, since some
  160. * applications provided certain features much earlier (as an example,
  161. * Microsoft Reader used subpixel and Y-direction ClearType already in
  162. * Windows 2000). Similarly, updates to a given framework might include
  163. * improved hinting support.
  164. *
  165. * {
  166. * version sampling rendering comment
  167. * x y x y
  168. * --------------------------------------------------------------
  169. * v1.0 normal normal B/W B/W bi-level
  170. * v1.6 high high gray gray grayscale
  171. * v1.8 high normal color-filter B/W (GDI) ClearType
  172. * v1.9 high high color-filter gray Color ClearType
  173. * v2.1 high normal gray B/W Gray ClearType
  174. * v2.1 high high gray gray Gray ClearType
  175. * }
  176. *
  177. * Color and Gray ClearType are the two available variants of
  178. * `Y-direction ClearType', meaning grayscale rasterization along the
  179. * Y-direction; the name used in the TrueType specification for this
  180. * feature is `symmetric smoothing'. `Classic ClearType' is the
  181. * original algorithm used before introducing a modified version in
  182. * Win~XP. Another name for v1.6's grayscale rendering is `font
  183. * smoothing', and `Color ClearType' is sometimes also called `DWrite
  184. * ClearType'. To differentiate between today's Color ClearType and the
  185. * earlier ClearType variant with B/W rendering along the vertical axis,
  186. * the latter is sometimes called `GDI ClearType'.
  187. *
  188. * `Normal' and `high' sampling describe the (virtual) resolution to
  189. * access the rasterized outline after the hinting process. `Normal'
  190. * means 1 sample per grid line (i.e., B/W). In the current Microsoft
  191. * implementation, `high' means an extra virtual resolution of 16x16 (or
  192. * 16x1) grid lines per pixel for bytecode instructions like `MIRP'.
  193. * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid
  194. * lines for color filtering if Color ClearType is activated.
  195. *
  196. * Note that `Gray ClearType' is essentially the same as v1.6's
  197. * grayscale rendering. However, the GETINFO instruction handles it
  198. * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1
  199. * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing),
  200. * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for
  201. * the version~1 gasp table exclusively (like Color ClearType), while
  202. * v1.6 only respects the values of version~0 (bits 0 and~1).
  203. *
  204. * FreeType doesn't provide all capabilities of the most recent
  205. * ClearType incarnation, thus we identify our subpixel support as
  206. * version~38.
  207. *
  208. */
  209. #define TT_INTERPRETER_VERSION_35 35
  210. #define TT_INTERPRETER_VERSION_38 38
  211. /* */
  212. FT_END_HEADER
  213. #endif /* __FTTTDRV_H__ */
  214. /* END */