/src/compiler/android-ndk/jni/freetype/src/truetype/ttobjs.h

http://ftk.googlecode.com/ · C++ Header · 431 lines · 149 code · 101 blank · 181 comment · 0 complexity · f6ae522e0c2ee7182712636d3323da62 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ttobjs.h */
  4. /* */
  5. /* Objects manager (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 __TTOBJS_H__
  18. #define __TTOBJS_H__
  19. #include <ft2build.h>
  20. #include FT_INTERNAL_OBJECTS_H
  21. #include FT_INTERNAL_TRUETYPE_TYPES_H
  22. FT_BEGIN_HEADER
  23. /*************************************************************************/
  24. /* */
  25. /* <Type> */
  26. /* TT_Driver */
  27. /* */
  28. /* <Description> */
  29. /* A handle to a TrueType driver object. */
  30. /* */
  31. typedef struct TT_DriverRec_* TT_Driver;
  32. /*************************************************************************/
  33. /* */
  34. /* <Type> */
  35. /* TT_Instance */
  36. /* */
  37. /* <Description> */
  38. /* A handle to a TrueType size object. */
  39. /* */
  40. typedef struct TT_SizeRec_* TT_Size;
  41. /*************************************************************************/
  42. /* */
  43. /* <Type> */
  44. /* TT_GlyphSlot */
  45. /* */
  46. /* <Description> */
  47. /* A handle to a TrueType glyph slot object. */
  48. /* */
  49. /* <Note> */
  50. /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
  51. /* specific about the TrueType glyph slot. */
  52. /* */
  53. typedef FT_GlyphSlot TT_GlyphSlot;
  54. /*************************************************************************/
  55. /* */
  56. /* <Struct> */
  57. /* TT_GraphicsState */
  58. /* */
  59. /* <Description> */
  60. /* The TrueType graphics state used during bytecode interpretation. */
  61. /* */
  62. typedef struct TT_GraphicsState_
  63. {
  64. FT_UShort rp0;
  65. FT_UShort rp1;
  66. FT_UShort rp2;
  67. FT_UnitVector dualVector;
  68. FT_UnitVector projVector;
  69. FT_UnitVector freeVector;
  70. #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
  71. FT_Bool both_x_axis;
  72. #endif
  73. FT_Long loop;
  74. FT_F26Dot6 minimum_distance;
  75. FT_Int round_state;
  76. FT_Bool auto_flip;
  77. FT_F26Dot6 control_value_cutin;
  78. FT_F26Dot6 single_width_cutin;
  79. FT_F26Dot6 single_width_value;
  80. FT_Short delta_base;
  81. FT_Short delta_shift;
  82. FT_Byte instruct_control;
  83. /* According to Greg Hitchcock from Microsoft, the `scan_control' */
  84. /* variable as documented in the TrueType specification is a 32-bit */
  85. /* integer; the high-word part holds the SCANTYPE value, the low-word */
  86. /* part the SCANCTRL value. We separate it into two fields. */
  87. FT_Bool scan_control;
  88. FT_Int scan_type;
  89. FT_UShort gep0;
  90. FT_UShort gep1;
  91. FT_UShort gep2;
  92. } TT_GraphicsState;
  93. #ifdef TT_USE_BYTECODE_INTERPRETER
  94. FT_LOCAL( void )
  95. tt_glyphzone_done( TT_GlyphZone zone );
  96. FT_LOCAL( FT_Error )
  97. tt_glyphzone_new( FT_Memory memory,
  98. FT_UShort maxPoints,
  99. FT_Short maxContours,
  100. TT_GlyphZone zone );
  101. #endif /* TT_USE_BYTECODE_INTERPRETER */
  102. /*************************************************************************/
  103. /* */
  104. /* EXECUTION SUBTABLES */
  105. /* */
  106. /* These sub-tables relate to instruction execution. */
  107. /* */
  108. /*************************************************************************/
  109. #define TT_MAX_CODE_RANGES 3
  110. /*************************************************************************/
  111. /* */
  112. /* There can only be 3 active code ranges at once: */
  113. /* - the Font Program */
  114. /* - the CVT Program */
  115. /* - a glyph's instructions set */
  116. /* */
  117. typedef enum TT_CodeRange_Tag_
  118. {
  119. tt_coderange_none = 0,
  120. tt_coderange_font,
  121. tt_coderange_cvt,
  122. tt_coderange_glyph
  123. } TT_CodeRange_Tag;
  124. typedef struct TT_CodeRange_
  125. {
  126. FT_Byte* base;
  127. FT_ULong size;
  128. } TT_CodeRange;
  129. typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
  130. /*************************************************************************/
  131. /* */
  132. /* Defines a function/instruction definition record. */
  133. /* */
  134. typedef struct TT_DefRecord_
  135. {
  136. FT_Int range; /* in which code range is it located? */
  137. FT_Long start; /* where does it start? */
  138. FT_UInt opc; /* function #, or instruction code */
  139. FT_Bool active; /* is it active? */
  140. } TT_DefRecord, *TT_DefArray;
  141. /*************************************************************************/
  142. /* */
  143. /* Subglyph transformation record. */
  144. /* */
  145. typedef struct TT_Transform_
  146. {
  147. FT_Fixed xx, xy; /* transformation matrix coefficients */
  148. FT_Fixed yx, yy;
  149. FT_F26Dot6 ox, oy; /* offsets */
  150. } TT_Transform;
  151. /*************************************************************************/
  152. /* */
  153. /* A note regarding non-squared pixels: */
  154. /* */
  155. /* (This text will probably go into some docs at some time; for now, it */
  156. /* is kept here to explain some definitions in the TT_Size_Metrics */
  157. /* record). */
  158. /* */
  159. /* The CVT is a one-dimensional array containing values that control */
  160. /* certain important characteristics in a font, like the height of all */
  161. /* capitals, all lowercase letter, default spacing or stem width/height. */
  162. /* */
  163. /* These values are found in FUnits in the font file, and must be scaled */
  164. /* to pixel coordinates before being used by the CVT and glyph programs. */
  165. /* Unfortunately, when using distinct x and y resolutions (or distinct x */
  166. /* and y pointsizes), there are two possible scalings. */
  167. /* */
  168. /* A first try was to implement a `lazy' scheme where all values were */
  169. /* scaled when first used. However, while some values are always used */
  170. /* in the same direction, some others are used under many different */
  171. /* circumstances and orientations. */
  172. /* */
  173. /* I have found a simpler way to do the same, and it even seems to work */
  174. /* in most of the cases: */
  175. /* */
  176. /* - All CVT values are scaled to the maximum ppem size. */
  177. /* */
  178. /* - When performing a read or write in the CVT, a ratio factor is used */
  179. /* to perform adequate scaling. Example: */
  180. /* */
  181. /* x_ppem = 14 */
  182. /* y_ppem = 10 */
  183. /* */
  184. /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
  185. /* entries are scaled to it. */
  186. /* */
  187. /* x_ratio = 1.0 */
  188. /* y_ratio = y_ppem/ppem (< 1.0) */
  189. /* */
  190. /* We compute the current ratio like: */
  191. /* */
  192. /* - If projVector is horizontal, */
  193. /* ratio = x_ratio = 1.0 */
  194. /* */
  195. /* - if projVector is vertical, */
  196. /* ratio = y_ratio */
  197. /* */
  198. /* - else, */
  199. /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
  200. /* */
  201. /* Reading a cvt value returns */
  202. /* ratio * cvt[index] */
  203. /* */
  204. /* Writing a cvt value in pixels: */
  205. /* cvt[index] / ratio */
  206. /* */
  207. /* The current ppem is simply */
  208. /* ratio * ppem */
  209. /* */
  210. /*************************************************************************/
  211. /*************************************************************************/
  212. /* */
  213. /* Metrics used by the TrueType size and context objects. */
  214. /* */
  215. typedef struct TT_Size_Metrics_
  216. {
  217. /* for non-square pixels */
  218. FT_Long x_ratio;
  219. FT_Long y_ratio;
  220. FT_UShort ppem; /* maximum ppem size */
  221. FT_Long ratio; /* current ratio */
  222. FT_Fixed scale;
  223. FT_F26Dot6 compensations[4]; /* device-specific compensations */
  224. FT_Bool valid;
  225. FT_Bool rotated; /* `is the glyph rotated?'-flag */
  226. FT_Bool stretched; /* `is the glyph stretched?'-flag */
  227. } TT_Size_Metrics;
  228. /*************************************************************************/
  229. /* */
  230. /* TrueType size class. */
  231. /* */
  232. typedef struct TT_SizeRec_
  233. {
  234. FT_SizeRec root;
  235. /* we have our own copy of metrics so that we can modify */
  236. /* it without affecting auto-hinting (when used) */
  237. FT_Size_Metrics metrics;
  238. TT_Size_Metrics ttmetrics;
  239. FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
  240. #ifdef TT_USE_BYTECODE_INTERPRETER
  241. FT_UInt num_function_defs; /* number of function definitions */
  242. FT_UInt max_function_defs;
  243. TT_DefArray function_defs; /* table of function definitions */
  244. FT_UInt num_instruction_defs; /* number of ins. definitions */
  245. FT_UInt max_instruction_defs;
  246. TT_DefArray instruction_defs; /* table of ins. definitions */
  247. FT_UInt max_func;
  248. FT_UInt max_ins;
  249. TT_CodeRangeTable codeRangeTable;
  250. TT_GraphicsState GS;
  251. FT_ULong cvt_size; /* the scaled control value table */
  252. FT_Long* cvt;
  253. FT_UShort storage_size; /* The storage area is now part of */
  254. FT_Long* storage; /* the instance */
  255. TT_GlyphZoneRec twilight; /* The instance's twilight zone */
  256. /* debugging variables */
  257. /* When using the debugger, we must keep the */
  258. /* execution context tied to the instance */
  259. /* object rather than asking it on demand. */
  260. FT_Bool debug;
  261. TT_ExecContext context;
  262. FT_Bool bytecode_ready;
  263. FT_Bool cvt_ready;
  264. #endif /* TT_USE_BYTECODE_INTERPRETER */
  265. } TT_SizeRec;
  266. /*************************************************************************/
  267. /* */
  268. /* TrueType driver class. */
  269. /* */
  270. typedef struct TT_DriverRec_
  271. {
  272. FT_DriverRec root;
  273. TT_ExecContext context; /* execution context */
  274. TT_GlyphZoneRec zone; /* glyph loader points zone */
  275. void* extension_component;
  276. } TT_DriverRec;
  277. /* Note: All of the functions below (except tt_size_reset()) are used */
  278. /* as function pointers in a FT_Driver_ClassRec. Therefore their */
  279. /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
  280. /* TT_Size, etc., so that the compiler can confirm that the types and */
  281. /* number of parameters are correct. In all cases the FT_xxx types are */
  282. /* cast to their TT_xxx counterparts inside the functions since FreeType */
  283. /* will always use the TT driver to create them. */
  284. /*************************************************************************/
  285. /* */
  286. /* Face functions */
  287. /* */
  288. FT_LOCAL( FT_Error )
  289. tt_face_init( FT_Stream stream,
  290. FT_Face ttface, /* TT_Face */
  291. FT_Int face_index,
  292. FT_Int num_params,
  293. FT_Parameter* params );
  294. FT_LOCAL( void )
  295. tt_face_done( FT_Face ttface ); /* TT_Face */
  296. /*************************************************************************/
  297. /* */
  298. /* Size functions */
  299. /* */
  300. FT_LOCAL( FT_Error )
  301. tt_size_init( FT_Size ttsize ); /* TT_Size */
  302. FT_LOCAL( void )
  303. tt_size_done( FT_Size ttsize ); /* TT_Size */
  304. #ifdef TT_USE_BYTECODE_INTERPRETER
  305. FT_LOCAL( FT_Error )
  306. tt_size_run_fpgm( TT_Size size );
  307. FT_LOCAL( FT_Error )
  308. tt_size_run_prep( TT_Size size );
  309. FT_LOCAL( FT_Error )
  310. tt_size_ready_bytecode( TT_Size size );
  311. #endif /* TT_USE_BYTECODE_INTERPRETER */
  312. FT_LOCAL( FT_Error )
  313. tt_size_reset( TT_Size size );
  314. /*************************************************************************/
  315. /* */
  316. /* Driver functions */
  317. /* */
  318. FT_LOCAL( FT_Error )
  319. tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
  320. FT_LOCAL( void )
  321. tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
  322. /*************************************************************************/
  323. /* */
  324. /* Slot functions */
  325. /* */
  326. FT_LOCAL( FT_Error )
  327. tt_slot_init( FT_GlyphSlot slot );
  328. FT_END_HEADER
  329. #endif /* __TTOBJS_H__ */
  330. /* END */