PageRenderTime 75ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/src/compiler/android-ndk/jni/freetype/include/freetype/internal/ftobjs.h

http://ftk.googlecode.com/
C++ Header | 1218 lines | 480 code | 205 blank | 533 comment | 7 complexity | c9d30cdfd9fda633f513f179185cd7d0 MD5 | raw file
Possible License(s): LGPL-3.0
  1. /***************************************************************************/
  2. /* */
  3. /* ftobjs.h */
  4. /* */
  5. /* The FreeType private base classes (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 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. /*************************************************************************/
  18. /* */
  19. /* This file contains the definition of all internal FreeType classes. */
  20. /* */
  21. /*************************************************************************/
  22. #ifndef __FTOBJS_H__
  23. #define __FTOBJS_H__
  24. #include <ft2build.h>
  25. #include FT_RENDER_H
  26. #include FT_SIZES_H
  27. #include FT_LCD_FILTER_H
  28. #include FT_INTERNAL_MEMORY_H
  29. #include FT_INTERNAL_GLYPH_LOADER_H
  30. #include FT_INTERNAL_DRIVER_H
  31. #include FT_INTERNAL_AUTOHINT_H
  32. #include FT_INTERNAL_SERVICE_H
  33. #include FT_INTERNAL_PIC_H
  34. #ifdef FT_CONFIG_OPTION_INCREMENTAL
  35. #include FT_INCREMENTAL_H
  36. #endif
  37. FT_BEGIN_HEADER
  38. /*************************************************************************/
  39. /* */
  40. /* Some generic definitions. */
  41. /* */
  42. #ifndef TRUE
  43. #define TRUE 1
  44. #endif
  45. #ifndef FALSE
  46. #define FALSE 0
  47. #endif
  48. #ifndef NULL
  49. #define NULL (void*)0
  50. #endif
  51. /*************************************************************************/
  52. /* */
  53. /* The min and max functions missing in C. As usual, be careful not to */
  54. /* write things like FT_MIN( a++, b++ ) to avoid side effects. */
  55. /* */
  56. #define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
  57. #define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
  58. #define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
  59. #define FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) )
  60. #define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + ((n)/2), n )
  61. #define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + ((n)-1), n )
  62. #define FT_PIX_FLOOR( x ) ( (x) & ~63 )
  63. #define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
  64. #define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
  65. /*
  66. * Return the highest power of 2 that is <= value; this correspond to
  67. * the highest bit in a given 32-bit value.
  68. */
  69. FT_BASE( FT_UInt32 )
  70. ft_highpow2( FT_UInt32 value );
  71. /*
  72. * character classification functions -- since these are used to parse
  73. * font files, we must not use those in <ctypes.h> which are
  74. * locale-dependent
  75. */
  76. #define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U )
  77. #define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \
  78. ( (unsigned)(x) - 'a' ) < 6U || \
  79. ( (unsigned)(x) - 'A' ) < 6U )
  80. /* the next two macros assume ASCII representation */
  81. #define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U )
  82. #define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U )
  83. #define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) )
  84. #define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) )
  85. /*************************************************************************/
  86. /*************************************************************************/
  87. /*************************************************************************/
  88. /**** ****/
  89. /**** ****/
  90. /**** C H A R M A P S ****/
  91. /**** ****/
  92. /**** ****/
  93. /*************************************************************************/
  94. /*************************************************************************/
  95. /*************************************************************************/
  96. /* handle to internal charmap object */
  97. typedef struct FT_CMapRec_* FT_CMap;
  98. /* handle to charmap class structure */
  99. typedef const struct FT_CMap_ClassRec_* FT_CMap_Class;
  100. /* internal charmap object structure */
  101. typedef struct FT_CMapRec_
  102. {
  103. FT_CharMapRec charmap;
  104. FT_CMap_Class clazz;
  105. } FT_CMapRec;
  106. /* typecase any pointer to a charmap handle */
  107. #define FT_CMAP( x ) ((FT_CMap)( x ))
  108. /* obvious macros */
  109. #define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id
  110. #define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id
  111. #define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding
  112. #define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face
  113. /* class method definitions */
  114. typedef FT_Error
  115. (*FT_CMap_InitFunc)( FT_CMap cmap,
  116. FT_Pointer init_data );
  117. typedef void
  118. (*FT_CMap_DoneFunc)( FT_CMap cmap );
  119. typedef FT_UInt
  120. (*FT_CMap_CharIndexFunc)( FT_CMap cmap,
  121. FT_UInt32 char_code );
  122. typedef FT_UInt
  123. (*FT_CMap_CharNextFunc)( FT_CMap cmap,
  124. FT_UInt32 *achar_code );
  125. typedef FT_UInt
  126. (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
  127. FT_CMap unicode_cmap,
  128. FT_UInt32 char_code,
  129. FT_UInt32 variant_selector );
  130. typedef FT_Bool
  131. (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
  132. FT_UInt32 char_code,
  133. FT_UInt32 variant_selector );
  134. typedef FT_UInt32 *
  135. (*FT_CMap_VariantListFunc)( FT_CMap cmap,
  136. FT_Memory mem );
  137. typedef FT_UInt32 *
  138. (*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
  139. FT_Memory mem,
  140. FT_UInt32 char_code );
  141. typedef FT_UInt32 *
  142. (*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
  143. FT_Memory mem,
  144. FT_UInt32 variant_selector );
  145. typedef struct FT_CMap_ClassRec_
  146. {
  147. FT_ULong size;
  148. FT_CMap_InitFunc init;
  149. FT_CMap_DoneFunc done;
  150. FT_CMap_CharIndexFunc char_index;
  151. FT_CMap_CharNextFunc char_next;
  152. /* Subsequent entries are special ones for format 14 -- the variant */
  153. /* selector subtable which behaves like no other */
  154. FT_CMap_CharVarIndexFunc char_var_index;
  155. FT_CMap_CharVarIsDefaultFunc char_var_default;
  156. FT_CMap_VariantListFunc variant_list;
  157. FT_CMap_CharVariantListFunc charvariant_list;
  158. FT_CMap_VariantCharListFunc variantchar_list;
  159. } FT_CMap_ClassRec;
  160. #ifndef FT_CONFIG_OPTION_PIC
  161. #define FT_DECLARE_CMAP_CLASS(class_) \
  162. FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
  163. #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
  164. char_next_, char_var_index_, char_var_default_, variant_list_, \
  165. charvariant_list_, variantchar_list_) \
  166. FT_CALLBACK_TABLE_DEF \
  167. const FT_CMap_ClassRec class_ = \
  168. { \
  169. size_, init_, done_, char_index_, char_next_, char_var_index_, \
  170. char_var_default_, variant_list_, charvariant_list_, variantchar_list_ \
  171. };
  172. #else /* FT_CONFIG_OPTION_PIC */
  173. #define FT_DECLARE_CMAP_CLASS(class_) \
  174. void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
  175. #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
  176. char_next_, char_var_index_, char_var_default_, variant_list_, \
  177. charvariant_list_, variantchar_list_) \
  178. void \
  179. FT_Init_Class_##class_( FT_Library library, \
  180. FT_CMap_ClassRec* clazz) \
  181. { \
  182. FT_UNUSED(library); \
  183. clazz->size = size_; \
  184. clazz->init = init_; \
  185. clazz->done = done_; \
  186. clazz->char_index = char_index_; \
  187. clazz->char_next = char_next_; \
  188. clazz->char_var_index = char_var_index_; \
  189. clazz->char_var_default = char_var_default_; \
  190. clazz->variant_list = variant_list_; \
  191. clazz->charvariant_list = charvariant_list_; \
  192. clazz->variantchar_list = variantchar_list_; \
  193. }
  194. #endif /* FT_CONFIG_OPTION_PIC */
  195. /* create a new charmap and add it to charmap->face */
  196. FT_BASE( FT_Error )
  197. FT_CMap_New( FT_CMap_Class clazz,
  198. FT_Pointer init_data,
  199. FT_CharMap charmap,
  200. FT_CMap *acmap );
  201. /* destroy a charmap and remove it from face's list */
  202. FT_BASE( void )
  203. FT_CMap_Done( FT_CMap cmap );
  204. /*************************************************************************/
  205. /* */
  206. /* <Struct> */
  207. /* FT_Face_InternalRec */
  208. /* */
  209. /* <Description> */
  210. /* This structure contains the internal fields of each FT_Face */
  211. /* object. These fields may change between different releases of */
  212. /* FreeType. */
  213. /* */
  214. /* <Fields> */
  215. /* max_points :: */
  216. /* The maximal number of points used to store the vectorial outline */
  217. /* of any glyph in this face. If this value cannot be known in */
  218. /* advance, or if the face isn't scalable, this should be set to 0. */
  219. /* Only relevant for scalable formats. */
  220. /* */
  221. /* max_contours :: */
  222. /* The maximal number of contours used to store the vectorial */
  223. /* outline of any glyph in this face. If this value cannot be */
  224. /* known in advance, or if the face isn't scalable, this should be */
  225. /* set to 0. Only relevant for scalable formats. */
  226. /* */
  227. /* transform_matrix :: */
  228. /* A 2x2 matrix of 16.16 coefficients used to transform glyph */
  229. /* outlines after they are loaded from the font. Only used by the */
  230. /* convenience functions. */
  231. /* */
  232. /* transform_delta :: */
  233. /* A translation vector used to transform glyph outlines after they */
  234. /* are loaded from the font. Only used by the convenience */
  235. /* functions. */
  236. /* */
  237. /* transform_flags :: */
  238. /* Some flags used to classify the transform. Only used by the */
  239. /* convenience functions. */
  240. /* */
  241. /* services :: */
  242. /* A cache for frequently used services. It should be only */
  243. /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */
  244. /* */
  245. /* incremental_interface :: */
  246. /* If non-null, the interface through which glyph data and metrics */
  247. /* are loaded incrementally for faces that do not provide all of */
  248. /* this data when first opened. This field exists only if */
  249. /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
  250. /* */
  251. /* ignore_unpatented_hinter :: */
  252. /* This boolean flag instructs the glyph loader to ignore the */
  253. /* native font hinter, if one is found. This is exclusively used */
  254. /* in the case when the unpatented hinter is compiled within the */
  255. /* library. */
  256. /* */
  257. typedef struct FT_Face_InternalRec_
  258. {
  259. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  260. FT_UShort reserved1;
  261. FT_Short reserved2;
  262. #endif
  263. FT_Matrix transform_matrix;
  264. FT_Vector transform_delta;
  265. FT_Int transform_flags;
  266. FT_ServiceCacheRec services;
  267. #ifdef FT_CONFIG_OPTION_INCREMENTAL
  268. FT_Incremental_InterfaceRec* incremental_interface;
  269. #endif
  270. FT_Bool ignore_unpatented_hinter;
  271. } FT_Face_InternalRec;
  272. /*************************************************************************/
  273. /* */
  274. /* <Struct> */
  275. /* FT_Slot_InternalRec */
  276. /* */
  277. /* <Description> */
  278. /* This structure contains the internal fields of each FT_GlyphSlot */
  279. /* object. These fields may change between different releases of */
  280. /* FreeType. */
  281. /* */
  282. /* <Fields> */
  283. /* loader :: The glyph loader object used to load outlines */
  284. /* into the glyph slot. */
  285. /* */
  286. /* flags :: Possible values are zero or */
  287. /* FT_GLYPH_OWN_BITMAP. The latter indicates */
  288. /* that the FT_GlyphSlot structure owns the */
  289. /* bitmap buffer. */
  290. /* */
  291. /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */
  292. /* must be transformed through a specific */
  293. /* font transformation. This is _not_ the same */
  294. /* as the face transform set through */
  295. /* FT_Set_Transform(). */
  296. /* */
  297. /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */
  298. /* transformation, if necessary. */
  299. /* */
  300. /* glyph_delta :: The 2d translation vector corresponding to */
  301. /* the glyph transformation, if necessary. */
  302. /* */
  303. /* glyph_hints :: Format-specific glyph hints management. */
  304. /* */
  305. #define FT_GLYPH_OWN_BITMAP 0x1
  306. typedef struct FT_Slot_InternalRec_
  307. {
  308. FT_GlyphLoader loader;
  309. FT_UInt flags;
  310. FT_Bool glyph_transformed;
  311. FT_Matrix glyph_matrix;
  312. FT_Vector glyph_delta;
  313. void* glyph_hints;
  314. } FT_GlyphSlot_InternalRec;
  315. #if 0
  316. /*************************************************************************/
  317. /* */
  318. /* <Struct> */
  319. /* FT_Size_InternalRec */
  320. /* */
  321. /* <Description> */
  322. /* This structure contains the internal fields of each FT_Size */
  323. /* object. Currently, it's empty. */
  324. /* */
  325. /*************************************************************************/
  326. typedef struct FT_Size_InternalRec_
  327. {
  328. /* empty */
  329. } FT_Size_InternalRec;
  330. #endif
  331. /*************************************************************************/
  332. /*************************************************************************/
  333. /**** ****/
  334. /**** ****/
  335. /**** M O D U L E S ****/
  336. /**** ****/
  337. /**** ****/
  338. /*************************************************************************/
  339. /*************************************************************************/
  340. /*************************************************************************/
  341. /*************************************************************************/
  342. /* */
  343. /* <Struct> */
  344. /* FT_ModuleRec */
  345. /* */
  346. /* <Description> */
  347. /* A module object instance. */
  348. /* */
  349. /* <Fields> */
  350. /* clazz :: A pointer to the module's class. */
  351. /* */
  352. /* library :: A handle to the parent library object. */
  353. /* */
  354. /* memory :: A handle to the memory manager. */
  355. /* */
  356. /* generic :: A generic structure for user-level extensibility (?). */
  357. /* */
  358. typedef struct FT_ModuleRec_
  359. {
  360. FT_Module_Class* clazz;
  361. FT_Library library;
  362. FT_Memory memory;
  363. FT_Generic generic;
  364. } FT_ModuleRec;
  365. /* typecast an object to a FT_Module */
  366. #define FT_MODULE( x ) ((FT_Module)( x ))
  367. #define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
  368. #define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
  369. #define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
  370. #define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  371. FT_MODULE_FONT_DRIVER )
  372. #define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  373. FT_MODULE_RENDERER )
  374. #define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  375. FT_MODULE_HINTER )
  376. #define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  377. FT_MODULE_STYLER )
  378. #define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  379. FT_MODULE_DRIVER_SCALABLE )
  380. #define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
  381. FT_MODULE_DRIVER_NO_OUTLINES )
  382. #define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  383. FT_MODULE_DRIVER_HAS_HINTER )
  384. /*************************************************************************/
  385. /* */
  386. /* <Function> */
  387. /* FT_Get_Module_Interface */
  388. /* */
  389. /* <Description> */
  390. /* Finds a module and returns its specific interface as a typeless */
  391. /* pointer. */
  392. /* */
  393. /* <Input> */
  394. /* library :: A handle to the library object. */
  395. /* */
  396. /* module_name :: The module's name (as an ASCII string). */
  397. /* */
  398. /* <Return> */
  399. /* A module-specific interface if available, 0 otherwise. */
  400. /* */
  401. /* <Note> */
  402. /* You should better be familiar with FreeType internals to know */
  403. /* which module to look for, and what its interface is :-) */
  404. /* */
  405. FT_BASE( const void* )
  406. FT_Get_Module_Interface( FT_Library library,
  407. const char* mod_name );
  408. FT_BASE( FT_Pointer )
  409. ft_module_get_service( FT_Module module,
  410. const char* service_id );
  411. /* */
  412. /*************************************************************************/
  413. /*************************************************************************/
  414. /*************************************************************************/
  415. /**** ****/
  416. /**** ****/
  417. /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
  418. /**** ****/
  419. /**** ****/
  420. /*************************************************************************/
  421. /*************************************************************************/
  422. /*************************************************************************/
  423. /* a few macros used to perform easy typecasts with minimal brain damage */
  424. #define FT_FACE( x ) ((FT_Face)(x))
  425. #define FT_SIZE( x ) ((FT_Size)(x))
  426. #define FT_SLOT( x ) ((FT_GlyphSlot)(x))
  427. #define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
  428. #define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
  429. #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
  430. #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
  431. #define FT_SIZE_FACE( x ) FT_SIZE( x )->face
  432. #define FT_SLOT_FACE( x ) FT_SLOT( x )->face
  433. #define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
  434. #define FT_FACE_SIZE( x ) FT_FACE( x )->size
  435. /*************************************************************************/
  436. /* */
  437. /* <Function> */
  438. /* FT_New_GlyphSlot */
  439. /* */
  440. /* <Description> */
  441. /* It is sometimes useful to have more than one glyph slot for a */
  442. /* given face object. This function is used to create additional */
  443. /* slots. All of them are automatically discarded when the face is */
  444. /* destroyed. */
  445. /* */
  446. /* <Input> */
  447. /* face :: A handle to a parent face object. */
  448. /* */
  449. /* <Output> */
  450. /* aslot :: A handle to a new glyph slot object. */
  451. /* */
  452. /* <Return> */
  453. /* FreeType error code. 0 means success. */
  454. /* */
  455. FT_BASE( FT_Error )
  456. FT_New_GlyphSlot( FT_Face face,
  457. FT_GlyphSlot *aslot );
  458. /*************************************************************************/
  459. /* */
  460. /* <Function> */
  461. /* FT_Done_GlyphSlot */
  462. /* */
  463. /* <Description> */
  464. /* Destroys a given glyph slot. Remember however that all slots are */
  465. /* automatically destroyed with its parent. Using this function is */
  466. /* not always mandatory. */
  467. /* */
  468. /* <Input> */
  469. /* slot :: A handle to a target glyph slot. */
  470. /* */
  471. FT_BASE( void )
  472. FT_Done_GlyphSlot( FT_GlyphSlot slot );
  473. /* */
  474. #define FT_REQUEST_WIDTH( req ) \
  475. ( (req)->horiResolution \
  476. ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
  477. : (req)->width )
  478. #define FT_REQUEST_HEIGHT( req ) \
  479. ( (req)->vertResolution \
  480. ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
  481. : (req)->height )
  482. /* Set the metrics according to a bitmap strike. */
  483. FT_BASE( void )
  484. FT_Select_Metrics( FT_Face face,
  485. FT_ULong strike_index );
  486. /* Set the metrics according to a size request. */
  487. FT_BASE( void )
  488. FT_Request_Metrics( FT_Face face,
  489. FT_Size_Request req );
  490. /* Match a size request against `available_sizes'. */
  491. FT_BASE( FT_Error )
  492. FT_Match_Size( FT_Face face,
  493. FT_Size_Request req,
  494. FT_Bool ignore_width,
  495. FT_ULong* size_index );
  496. /* Use the horizontal metrics to synthesize the vertical metrics. */
  497. /* If `advance' is zero, it is also synthesized. */
  498. FT_BASE( void )
  499. ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
  500. FT_Pos advance );
  501. /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
  502. /* was allocated with ft_glyphslot_alloc_bitmap). */
  503. FT_BASE( void )
  504. ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
  505. /* Allocate a new bitmap buffer in a glyph slot. */
  506. FT_BASE( FT_Error )
  507. ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
  508. FT_ULong size );
  509. /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
  510. /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
  511. FT_BASE( void )
  512. ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
  513. FT_Byte* buffer );
  514. /*************************************************************************/
  515. /*************************************************************************/
  516. /*************************************************************************/
  517. /**** ****/
  518. /**** ****/
  519. /**** R E N D E R E R S ****/
  520. /**** ****/
  521. /**** ****/
  522. /*************************************************************************/
  523. /*************************************************************************/
  524. /*************************************************************************/
  525. #define FT_RENDERER( x ) ((FT_Renderer)( x ))
  526. #define FT_GLYPH( x ) ((FT_Glyph)( x ))
  527. #define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
  528. #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
  529. typedef struct FT_RendererRec_
  530. {
  531. FT_ModuleRec root;
  532. FT_Renderer_Class* clazz;
  533. FT_Glyph_Format glyph_format;
  534. FT_Glyph_Class glyph_class;
  535. FT_Raster raster;
  536. FT_Raster_Render_Func raster_render;
  537. FT_Renderer_RenderFunc render;
  538. } FT_RendererRec;
  539. /*************************************************************************/
  540. /*************************************************************************/
  541. /*************************************************************************/
  542. /**** ****/
  543. /**** ****/
  544. /**** F O N T D R I V E R S ****/
  545. /**** ****/
  546. /**** ****/
  547. /*************************************************************************/
  548. /*************************************************************************/
  549. /*************************************************************************/
  550. /* typecast a module into a driver easily */
  551. #define FT_DRIVER( x ) ((FT_Driver)(x))
  552. /* typecast a module as a driver, and get its driver class */
  553. #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
  554. /*************************************************************************/
  555. /* */
  556. /* <Struct> */
  557. /* FT_DriverRec */
  558. /* */
  559. /* <Description> */
  560. /* The root font driver class. A font driver is responsible for */
  561. /* managing and loading font files of a given format. */
  562. /* */
  563. /* <Fields> */
  564. /* root :: Contains the fields of the root module class. */
  565. /* */
  566. /* clazz :: A pointer to the font driver's class. Note that */
  567. /* this is NOT root.clazz. `class' wasn't used */
  568. /* as it is a reserved word in C++. */
  569. /* */
  570. /* faces_list :: The list of faces currently opened by this */
  571. /* driver. */
  572. /* */
  573. /* extensions :: A typeless pointer to the driver's extensions */
  574. /* registry, if they are supported through the */
  575. /* configuration macro FT_CONFIG_OPTION_EXTENSIONS. */
  576. /* */
  577. /* glyph_loader :: The glyph loader for all faces managed by this */
  578. /* driver. This object isn't defined for unscalable */
  579. /* formats. */
  580. /* */
  581. typedef struct FT_DriverRec_
  582. {
  583. FT_ModuleRec root;
  584. FT_Driver_Class clazz;
  585. FT_ListRec faces_list;
  586. void* extensions;
  587. FT_GlyphLoader glyph_loader;
  588. } FT_DriverRec;
  589. /*************************************************************************/
  590. /*************************************************************************/
  591. /*************************************************************************/
  592. /**** ****/
  593. /**** ****/
  594. /**** L I B R A R I E S ****/
  595. /**** ****/
  596. /**** ****/
  597. /*************************************************************************/
  598. /*************************************************************************/
  599. /*************************************************************************/
  600. /* This hook is used by the TrueType debugger. It must be set to an */
  601. /* alternate truetype bytecode interpreter function. */
  602. #define FT_DEBUG_HOOK_TRUETYPE 0
  603. /* Set this debug hook to a non-null pointer to force unpatented hinting */
  604. /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */
  605. /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */
  606. /* during debugging. */
  607. #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1
  608. typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
  609. FT_Render_Mode render_mode,
  610. FT_Library library );
  611. /*************************************************************************/
  612. /* */
  613. /* <Struct> */
  614. /* FT_LibraryRec */
  615. /* */
  616. /* <Description> */
  617. /* The FreeType library class. This is the root of all FreeType */
  618. /* data. Use FT_New_Library() to create a library object, and */
  619. /* FT_Done_Library() to discard it and all child objects. */
  620. /* */
  621. /* <Fields> */
  622. /* memory :: The library's memory object. Manages memory */
  623. /* allocation. */
  624. /* */
  625. /* generic :: Client data variable. Used to extend the */
  626. /* Library class by higher levels and clients. */
  627. /* */
  628. /* version_major :: The major version number of the library. */
  629. /* */
  630. /* version_minor :: The minor version number of the library. */
  631. /* */
  632. /* version_patch :: The current patch level of the library. */
  633. /* */
  634. /* num_modules :: The number of modules currently registered */
  635. /* within this library. This is set to 0 for new */
  636. /* libraries. New modules are added through the */
  637. /* FT_Add_Module() API function. */
  638. /* */
  639. /* modules :: A table used to store handles to the currently */
  640. /* registered modules. Note that each font driver */
  641. /* contains a list of its opened faces. */
  642. /* */
  643. /* renderers :: The list of renderers currently registered */
  644. /* within the library. */
  645. /* */
  646. /* cur_renderer :: The current outline renderer. This is a */
  647. /* shortcut used to avoid parsing the list on */
  648. /* each call to FT_Outline_Render(). It is a */
  649. /* handle to the current renderer for the */
  650. /* FT_GLYPH_FORMAT_OUTLINE format. */
  651. /* */
  652. /* auto_hinter :: XXX */
  653. /* */
  654. /* raster_pool :: The raster object's render pool. This can */
  655. /* ideally be changed dynamically at run-time. */
  656. /* */
  657. /* raster_pool_size :: The size of the render pool in bytes. */
  658. /* */
  659. /* debug_hooks :: XXX */
  660. /* */
  661. /* pic_container :: Contains global structs and tables, instead */
  662. /* of defining them globallly. */
  663. /* */
  664. typedef struct FT_LibraryRec_
  665. {
  666. FT_Memory memory; /* library's memory manager */
  667. FT_Generic generic;
  668. FT_Int version_major;
  669. FT_Int version_minor;
  670. FT_Int version_patch;
  671. FT_UInt num_modules;
  672. FT_Module modules[FT_MAX_MODULES]; /* module objects */
  673. FT_ListRec renderers; /* list of renderers */
  674. FT_Renderer cur_renderer; /* current outline renderer */
  675. FT_Module auto_hinter;
  676. FT_Byte* raster_pool; /* scan-line conversion */
  677. /* render pool */
  678. FT_ULong raster_pool_size; /* size of render pool in bytes */
  679. FT_DebugHook_Func debug_hooks[4];
  680. #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
  681. FT_LcdFilter lcd_filter;
  682. FT_Int lcd_extra; /* number of extra pixels */
  683. FT_Byte lcd_weights[7]; /* filter weights, if any */
  684. FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
  685. #endif
  686. #ifdef FT_CONFIG_OPTION_PIC
  687. FT_PIC_Container pic_container;
  688. #endif
  689. } FT_LibraryRec;
  690. FT_BASE( FT_Renderer )
  691. FT_Lookup_Renderer( FT_Library library,
  692. FT_Glyph_Format format,
  693. FT_ListNode* node );
  694. FT_BASE( FT_Error )
  695. FT_Render_Glyph_Internal( FT_Library library,
  696. FT_GlyphSlot slot,
  697. FT_Render_Mode render_mode );
  698. typedef const char*
  699. (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
  700. typedef FT_Error
  701. (*FT_Face_GetGlyphNameFunc)( FT_Face face,
  702. FT_UInt glyph_index,
  703. FT_Pointer buffer,
  704. FT_UInt buffer_max );
  705. typedef FT_UInt
  706. (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
  707. FT_String* glyph_name );
  708. #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
  709. /*************************************************************************/
  710. /* */
  711. /* <Function> */
  712. /* FT_New_Memory */
  713. /* */
  714. /* <Description> */
  715. /* Creates a new memory object. */
  716. /* */
  717. /* <Return> */
  718. /* A pointer to the new memory object. 0 in case of error. */
  719. /* */
  720. FT_BASE( FT_Memory )
  721. FT_New_Memory( void );
  722. /*************************************************************************/
  723. /* */
  724. /* <Function> */
  725. /* FT_Done_Memory */
  726. /* */
  727. /* <Description> */
  728. /* Discards memory manager. */
  729. /* */
  730. /* <Input> */
  731. /* memory :: A handle to the memory manager. */
  732. /* */
  733. FT_BASE( void )
  734. FT_Done_Memory( FT_Memory memory );
  735. #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
  736. /* Define default raster's interface. The default raster is located in */
  737. /* `src/base/ftraster.c'. */
  738. /* */
  739. /* Client applications can register new rasters through the */
  740. /* FT_Set_Raster() API. */
  741. #ifndef FT_NO_DEFAULT_RASTER
  742. FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
  743. #endif
  744. /*************************************************************************/
  745. /*************************************************************************/
  746. /*************************************************************************/
  747. /**** ****/
  748. /**** ****/
  749. /**** PIC-Support Macros for ftimage.h ****/
  750. /**** ****/
  751. /**** ****/
  752. /*************************************************************************/
  753. /*************************************************************************/
  754. /*************************************************************************/
  755. /*************************************************************************/
  756. /* */
  757. /* <Macro> */
  758. /* FT_DEFINE_OUTLINE_FUNCS */
  759. /* */
  760. /* <Description> */
  761. /* Used to initialize an instance of FT_Outline_Funcs struct. */
  762. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  763. /* called with a pre-allocated stracture to be filled. */
  764. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  765. /* allocated in the global scope (or the scope where the macro */
  766. /* is used). */
  767. /* */
  768. #ifndef FT_CONFIG_OPTION_PIC
  769. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  770. cubic_to_, shift_, delta_) \
  771. static const FT_Outline_Funcs class_ = \
  772. { \
  773. move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
  774. };
  775. #else /* FT_CONFIG_OPTION_PIC */
  776. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  777. cubic_to_, shift_, delta_) \
  778. static FT_Error \
  779. Init_Class_##class_( FT_Outline_Funcs* clazz ) \
  780. { \
  781. clazz->move_to = move_to_; \
  782. clazz->line_to = line_to_; \
  783. clazz->conic_to = conic_to_; \
  784. clazz->cubic_to = cubic_to_; \
  785. clazz->shift = shift_; \
  786. clazz->delta = delta_; \
  787. return FT_Err_Ok; \
  788. }
  789. #endif /* FT_CONFIG_OPTION_PIC */
  790. /*************************************************************************/
  791. /* */
  792. /* <Macro> */
  793. /* FT_DEFINE_RASTER_FUNCS */
  794. /* */
  795. /* <Description> */
  796. /* Used to initialize an instance of FT_Raster_Funcs struct. */
  797. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  798. /* called with a pre-allocated stracture to be filled. */
  799. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  800. /* allocated in the global scope (or the scope where the macro */
  801. /* is used). */
  802. /* */
  803. #ifndef FT_CONFIG_OPTION_PIC
  804. #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
  805. raster_reset_, raster_set_mode_, \
  806. raster_render_, raster_done_) \
  807. const FT_Raster_Funcs class_ = \
  808. { \
  809. glyph_format_, raster_new_, raster_reset_, \
  810. raster_set_mode_, raster_render_, raster_done_ \
  811. };
  812. #else /* FT_CONFIG_OPTION_PIC */
  813. #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
  814. raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
  815. void \
  816. FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
  817. { \
  818. clazz->glyph_format = glyph_format_; \
  819. clazz->raster_new = raster_new_; \
  820. clazz->raster_reset = raster_reset_; \
  821. clazz->raster_set_mode = raster_set_mode_; \
  822. clazz->raster_render = raster_render_; \
  823. clazz->raster_done = raster_done_; \
  824. }
  825. #endif /* FT_CONFIG_OPTION_PIC */
  826. /*************************************************************************/
  827. /*************************************************************************/
  828. /*************************************************************************/
  829. /**** ****/
  830. /**** ****/
  831. /**** PIC-Support Macros for ftrender.h ****/
  832. /**** ****/
  833. /**** ****/
  834. /*************************************************************************/
  835. /*************************************************************************/
  836. /*************************************************************************/
  837. /*************************************************************************/
  838. /* */
  839. /* <Macro> */
  840. /* FT_DEFINE_GLYPH */
  841. /* */
  842. /* <Description> */
  843. /* Used to initialize an instance of FT_Glyph_Class struct. */
  844. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  845. /* called with a pre-allocated stracture to be filled. */
  846. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  847. /* allocated in the global scope (or the scope where the macro */
  848. /* is used). */
  849. /* */
  850. #ifndef FT_CONFIG_OPTION_PIC
  851. #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
  852. transform_, bbox_, prepare_) \
  853. FT_CALLBACK_TABLE_DEF \
  854. const FT_Glyph_Class class_ = \
  855. { \
  856. size_, format_, init_, done_, copy_, transform_, bbox_, prepare_ \
  857. };
  858. #else /* FT_CONFIG_OPTION_PIC */
  859. #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
  860. transform_, bbox_, prepare_) \
  861. void \
  862. FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
  863. { \
  864. clazz->glyph_size = size_; \
  865. clazz->glyph_format = format_; \
  866. clazz->glyph_init = init_; \
  867. clazz->glyph_done = done_; \
  868. clazz->glyph_copy = copy_; \
  869. clazz->glyph_transform = transform_; \
  870. clazz->glyph_bbox = bbox_; \
  871. clazz->glyph_prepare = prepare_; \
  872. }
  873. #endif /* FT_CONFIG_OPTION_PIC */
  874. /*************************************************************************/
  875. /* */
  876. /* <Macro> */
  877. /* FT_DECLARE_RENDERER */
  878. /* */
  879. /* <Description> */
  880. /* Used to create a forward declaration of a */
  881. /* FT_Renderer_Class stract instance. */
  882. /* */
  883. /* <Macro> */
  884. /* FT_DEFINE_RENDERER */
  885. /* */
  886. /* <Description> */
  887. /* Used to initialize an instance of FT_Renderer_Class struct. */
  888. /* */
  889. /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
  890. /* to called with a pointer where the allocated stracture is returned.*/
  891. /* And when it is no longer needed a Destroy function needs */
  892. /* to be called to release that allocation. */
  893. /* fcinit.c (ft_create_default_module_classes) already contains */
  894. /* a mechanism to call these functions for the default modules */
  895. /* described in ftmodule.h */
  896. /* */
  897. /* Notice that the created Create and Destroy functions call */
  898. /* pic_init and pic_free function to allow you to manually allocate */
  899. /* and initialize any additional global data, like module specific */
  900. /* interface, and put them in the global pic container defined in */
  901. /* ftpic.h. if you don't need them just implement the functions as */
  902. /* empty to resolve the link error. */
  903. /* */
  904. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  905. /* allocated in the global scope (or the scope where the macro */
  906. /* is used). */
  907. /* */
  908. #ifndef FT_CONFIG_OPTION_PIC
  909. #define FT_DECLARE_RENDERER(class_) \
  910. FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
  911. #define FT_DEFINE_RENDERER(class_, \
  912. flags_, size_, name_, version_, requires_, \
  913. interface_, init_, done_, get_interface_, \
  914. glyph_format_, render_glyph_, transform_glyph_, \
  915. get_glyph_cbox_, set_mode_, raster_class_ ) \
  916. FT_CALLBACK_TABLE_DEF \
  917. const FT_Renderer_Class class_ = \
  918. { \
  919. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
  920. interface_,init_,done_,get_interface_) \
  921. glyph_format_, \
  922. \
  923. render_glyph_, \
  924. transform_glyph_, \
  925. get_glyph_cbox_, \
  926. set_mode_, \
  927. \
  928. raster_class_ \
  929. };
  930. #else /* FT_CONFIG_OPTION_PIC */
  931. #define FT_DECLARE_RENDERER(class_) FT_DECLARE_MODULE(class_)
  932. #define FT_DEFINE_RENDERER(class_, \
  933. flags_, size_, name_, version_, requires_, \
  934. interface_, init_, done_, get_interface_, \
  935. glyph_format_, render_glyph_, transform_glyph_, \
  936. get_glyph_cbox_, set_mode_, raster_class_ ) \
  937. void class_##_pic_free( FT_Library library ); \
  938. FT_Error class_##_pic_init( FT_Library library ); \
  939. \
  940. void \
  941. FT_Destroy_Class_##class_( FT_Library library, \
  942. FT_Module_Class* clazz ) \
  943. { \
  944. FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
  945. FT_Memory memory = library->memory; \
  946. class_##_pic_free( library ); \
  947. if ( rclazz ) \
  948. FT_FREE( rclazz ); \
  949. } \
  950. \
  951. FT_Error \
  952. FT_Create_Class_##class_( FT_Library library, \
  953. FT_Module_Class** output_class ) \
  954. { \
  955. FT_Renderer_Class* clazz; \
  956. FT_Error error; \
  957. FT_Memory memory = library->memory; \
  958. \
  959. if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
  960. return error; \
  961. \
  962. error = class_##_pic_init( library ); \
  963. if(error) \
  964. { \
  965. FT_FREE( clazz ); \
  966. return error; \
  967. } \
  968. \
  969. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
  970. interface_,init_,done_,get_interface_) \
  971. \
  972. clazz->glyph_format = glyph_format_; \
  973. \
  974. clazz->render_glyph = render_glyph_; \
  975. clazz->transform_glyph = transform_glyph_; \
  976. clazz->get_glyph_cbox = get_glyph_cbox_; \
  977. clazz->set_mode = set_mode_; \
  978. \
  979. clazz->raster_class = raster_class_; \
  980. \
  981. *output_class = (FT_Module_Class*)clazz; \
  982. return FT_Err_Ok; \
  983. }
  984. #endif /* FT_CONFIG_OPTION_PIC */
  985. /*************************************************************************/
  986. /*************************************************************************/
  987. /*************************************************************************/
  988. /**** ****/
  989. /**** ****/
  990. /**** PIC-Support Macros for ftmodapi.h ****/
  991. /**** ****/
  992. /**** ****/
  993. /*************************************************************************/
  994. /*************************************************************************/
  995. /*************************************************************************/
  996. #ifdef FT_CONFIG_OPTION_PIC
  997. /*************************************************************************/
  998. /* */
  999. /* <FuncType> */
  1000. /* FT_Module_Creator */
  1001. /* */
  1002. /* <Description> */
  1003. /* A function used to create (allocate) a new module class object. */
  1004. /* The object's members are initialized, but the module itself is */
  1005. /* not. */
  1006. /* */
  1007. /* <Input> */
  1008. /* memory :: A handle to the memory manager. */
  1009. /* output_class :: Initialized with the newly allocated class. */
  1010. /* */
  1011. typedef FT_Error
  1012. (*FT_Module_Creator)( FT_Memory memory,
  1013. FT_Module_Class** output_cl