/src/freetype/include/freetype/internal/ftobjs.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 1413 lines · 586 code · 219 blank · 608 comment · 10 complexity · 4a42af2399651b5968d6be3025b6a4dd MD5 · raw file

Large files are truncated click here to view the full file

  1. /***************************************************************************/
  2. /* */
  3. /* ftobjs.h */
  4. /* */
  5. /* The FreeType private base classes (specification). */
  6. /* */
  7. /* Copyright 1996-2006, 2008, 2010, 2012 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. /* refcount :: */
  258. /* A counter initialized to~1 at the time an @FT_Face structure is */
  259. /* created. @FT_Reference_Face increments this counter, and */
  260. /* @FT_Done_Face only destroys a face if the counter is~1, */
  261. /* otherwise it simply decrements it. */
  262. /* */
  263. typedef struct FT_Face_InternalRec_
  264. {
  265. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  266. FT_UShort reserved1;
  267. FT_Short reserved2;
  268. #endif
  269. FT_Matrix transform_matrix;
  270. FT_Vector transform_delta;
  271. FT_Int transform_flags;
  272. FT_ServiceCacheRec services;
  273. #ifdef FT_CONFIG_OPTION_INCREMENTAL
  274. FT_Incremental_InterfaceRec* incremental_interface;
  275. #endif
  276. FT_Bool ignore_unpatented_hinter;
  277. FT_UInt refcount;
  278. } FT_Face_InternalRec;
  279. /*************************************************************************/
  280. /* */
  281. /* <Struct> */
  282. /* FT_Slot_InternalRec */
  283. /* */
  284. /* <Description> */
  285. /* This structure contains the internal fields of each FT_GlyphSlot */
  286. /* object. These fields may change between different releases of */
  287. /* FreeType. */
  288. /* */
  289. /* <Fields> */
  290. /* loader :: The glyph loader object used to load outlines */
  291. /* into the glyph slot. */
  292. /* */
  293. /* flags :: Possible values are zero or */
  294. /* FT_GLYPH_OWN_BITMAP. The latter indicates */
  295. /* that the FT_GlyphSlot structure owns the */
  296. /* bitmap buffer. */
  297. /* */
  298. /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */
  299. /* must be transformed through a specific */
  300. /* font transformation. This is _not_ the same */
  301. /* as the face transform set through */
  302. /* FT_Set_Transform(). */
  303. /* */
  304. /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */
  305. /* transformation, if necessary. */
  306. /* */
  307. /* glyph_delta :: The 2d translation vector corresponding to */
  308. /* the glyph transformation, if necessary. */
  309. /* */
  310. /* glyph_hints :: Format-specific glyph hints management. */
  311. /* */
  312. #define FT_GLYPH_OWN_BITMAP 0x1
  313. typedef struct FT_Slot_InternalRec_
  314. {
  315. FT_GlyphLoader loader;
  316. FT_UInt flags;
  317. FT_Bool glyph_transformed;
  318. FT_Matrix glyph_matrix;
  319. FT_Vector glyph_delta;
  320. void* glyph_hints;
  321. } FT_GlyphSlot_InternalRec;
  322. #if 0
  323. /*************************************************************************/
  324. /* */
  325. /* <Struct> */
  326. /* FT_Size_InternalRec */
  327. /* */
  328. /* <Description> */
  329. /* This structure contains the internal fields of each FT_Size */
  330. /* object. Currently, it's empty. */
  331. /* */
  332. /*************************************************************************/
  333. typedef struct FT_Size_InternalRec_
  334. {
  335. /* empty */
  336. } FT_Size_InternalRec;
  337. #endif
  338. /*************************************************************************/
  339. /*************************************************************************/
  340. /**** ****/
  341. /**** ****/
  342. /**** M O D U L E S ****/
  343. /**** ****/
  344. /**** ****/
  345. /*************************************************************************/
  346. /*************************************************************************/
  347. /*************************************************************************/
  348. /*************************************************************************/
  349. /* */
  350. /* <Struct> */
  351. /* FT_ModuleRec */
  352. /* */
  353. /* <Description> */
  354. /* A module object instance. */
  355. /* */
  356. /* <Fields> */
  357. /* clazz :: A pointer to the module's class. */
  358. /* */
  359. /* library :: A handle to the parent library object. */
  360. /* */
  361. /* memory :: A handle to the memory manager. */
  362. /* */
  363. typedef struct FT_ModuleRec_
  364. {
  365. FT_Module_Class* clazz;
  366. FT_Library library;
  367. FT_Memory memory;
  368. } FT_ModuleRec;
  369. /* typecast an object to an FT_Module */
  370. #define FT_MODULE( x ) ((FT_Module)( x ))
  371. #define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
  372. #define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
  373. #define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
  374. #define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  375. FT_MODULE_FONT_DRIVER )
  376. #define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  377. FT_MODULE_RENDERER )
  378. #define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  379. FT_MODULE_HINTER )
  380. #define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  381. FT_MODULE_STYLER )
  382. #define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  383. FT_MODULE_DRIVER_SCALABLE )
  384. #define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
  385. FT_MODULE_DRIVER_NO_OUTLINES )
  386. #define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  387. FT_MODULE_DRIVER_HAS_HINTER )
  388. /*************************************************************************/
  389. /* */
  390. /* <Function> */
  391. /* FT_Get_Module_Interface */
  392. /* */
  393. /* <Description> */
  394. /* Finds a module and returns its specific interface as a typeless */
  395. /* pointer. */
  396. /* */
  397. /* <Input> */
  398. /* library :: A handle to the library object. */
  399. /* */
  400. /* module_name :: The module's name (as an ASCII string). */
  401. /* */
  402. /* <Return> */
  403. /* A module-specific interface if available, 0 otherwise. */
  404. /* */
  405. /* <Note> */
  406. /* You should better be familiar with FreeType internals to know */
  407. /* which module to look for, and what its interface is :-) */
  408. /* */
  409. FT_BASE( const void* )
  410. FT_Get_Module_Interface( FT_Library library,
  411. const char* mod_name );
  412. FT_BASE( FT_Pointer )
  413. ft_module_get_service( FT_Module module,
  414. const char* service_id );
  415. /* */
  416. /*************************************************************************/
  417. /*************************************************************************/
  418. /*************************************************************************/
  419. /**** ****/
  420. /**** ****/
  421. /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
  422. /**** ****/
  423. /**** ****/
  424. /*************************************************************************/
  425. /*************************************************************************/
  426. /*************************************************************************/
  427. /* a few macros used to perform easy typecasts with minimal brain damage */
  428. #define FT_FACE( x ) ((FT_Face)(x))
  429. #define FT_SIZE( x ) ((FT_Size)(x))
  430. #define FT_SLOT( x ) ((FT_GlyphSlot)(x))
  431. #define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
  432. #define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
  433. #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
  434. #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
  435. #define FT_SIZE_FACE( x ) FT_SIZE( x )->face
  436. #define FT_SLOT_FACE( x ) FT_SLOT( x )->face
  437. #define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
  438. #define FT_FACE_SIZE( x ) FT_FACE( x )->size
  439. /*************************************************************************/
  440. /* */
  441. /* <Function> */
  442. /* FT_New_GlyphSlot */
  443. /* */
  444. /* <Description> */
  445. /* It is sometimes useful to have more than one glyph slot for a */
  446. /* given face object. This function is used to create additional */
  447. /* slots. All of them are automatically discarded when the face is */
  448. /* destroyed. */
  449. /* */
  450. /* <Input> */
  451. /* face :: A handle to a parent face object. */
  452. /* */
  453. /* <Output> */
  454. /* aslot :: A handle to a new glyph slot object. */
  455. /* */
  456. /* <Return> */
  457. /* FreeType error code. 0 means success. */
  458. /* */
  459. FT_BASE( FT_Error )
  460. FT_New_GlyphSlot( FT_Face face,
  461. FT_GlyphSlot *aslot );
  462. /*************************************************************************/
  463. /* */
  464. /* <Function> */
  465. /* FT_Done_GlyphSlot */
  466. /* */
  467. /* <Description> */
  468. /* Destroys a given glyph slot. Remember however that all slots are */
  469. /* automatically destroyed with its parent. Using this function is */
  470. /* not always mandatory. */
  471. /* */
  472. /* <Input> */
  473. /* slot :: A handle to a target glyph slot. */
  474. /* */
  475. FT_BASE( void )
  476. FT_Done_GlyphSlot( FT_GlyphSlot slot );
  477. /* */
  478. #define FT_REQUEST_WIDTH( req ) \
  479. ( (req)->horiResolution \
  480. ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
  481. : (req)->width )
  482. #define FT_REQUEST_HEIGHT( req ) \
  483. ( (req)->vertResolution \
  484. ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
  485. : (req)->height )
  486. /* Set the metrics according to a bitmap strike. */
  487. FT_BASE( void )
  488. FT_Select_Metrics( FT_Face face,
  489. FT_ULong strike_index );
  490. /* Set the metrics according to a size request. */
  491. FT_BASE( void )
  492. FT_Request_Metrics( FT_Face face,
  493. FT_Size_Request req );
  494. /* Match a size request against `available_sizes'. */
  495. FT_BASE( FT_Error )
  496. FT_Match_Size( FT_Face face,
  497. FT_Size_Request req,
  498. FT_Bool ignore_width,
  499. FT_ULong* size_index );
  500. /* Use the horizontal metrics to synthesize the vertical metrics. */
  501. /* If `advance' is zero, it is also synthesized. */
  502. FT_BASE( void )
  503. ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
  504. FT_Pos advance );
  505. /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
  506. /* was allocated with ft_glyphslot_alloc_bitmap). */
  507. FT_BASE( void )
  508. ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
  509. /* Allocate a new bitmap buffer in a glyph slot. */
  510. FT_BASE( FT_Error )
  511. ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
  512. FT_ULong size );
  513. /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
  514. /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
  515. FT_BASE( void )
  516. ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
  517. FT_Byte* buffer );
  518. /*************************************************************************/
  519. /*************************************************************************/
  520. /*************************************************************************/
  521. /**** ****/
  522. /**** ****/
  523. /**** R E N D E R E R S ****/
  524. /**** ****/
  525. /**** ****/
  526. /*************************************************************************/
  527. /*************************************************************************/
  528. /*************************************************************************/
  529. #define FT_RENDERER( x ) ((FT_Renderer)( x ))
  530. #define FT_GLYPH( x ) ((FT_Glyph)( x ))
  531. #define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
  532. #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
  533. typedef struct FT_RendererRec_
  534. {
  535. FT_ModuleRec root;
  536. FT_Renderer_Class* clazz;
  537. FT_Glyph_Format glyph_format;
  538. FT_Glyph_Class glyph_class;
  539. FT_Raster raster;
  540. FT_Raster_Render_Func raster_render;
  541. FT_Renderer_RenderFunc render;
  542. } FT_RendererRec;
  543. /*************************************************************************/
  544. /*************************************************************************/
  545. /*************************************************************************/
  546. /**** ****/
  547. /**** ****/
  548. /**** F O N T D R I V E R S ****/
  549. /**** ****/
  550. /**** ****/
  551. /*************************************************************************/
  552. /*************************************************************************/
  553. /*************************************************************************/
  554. /* typecast a module into a driver easily */
  555. #define FT_DRIVER( x ) ((FT_Driver)(x))
  556. /* typecast a module as a driver, and get its driver class */
  557. #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
  558. /*************************************************************************/
  559. /* */
  560. /* <Struct> */
  561. /* FT_DriverRec */
  562. /* */
  563. /* <Description> */
  564. /* The root font driver class. A font driver is responsible for */
  565. /* managing and loading font files of a given format. */
  566. /* */
  567. /* <Fields> */
  568. /* root :: Contains the fields of the root module class. */
  569. /* */
  570. /* clazz :: A pointer to the font driver's class. Note that */
  571. /* this is NOT root.clazz. `class' wasn't used */
  572. /* as it is a reserved word in C++. */
  573. /* */
  574. /* faces_list :: The list of faces currently opened by this */
  575. /* driver. */
  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. FT_GlyphLoader glyph_loader;
  587. } FT_DriverRec;
  588. /*************************************************************************/
  589. /*************************************************************************/
  590. /*************************************************************************/
  591. /**** ****/
  592. /**** ****/
  593. /**** L I B R A R I E S ****/
  594. /**** ****/
  595. /**** ****/
  596. /*************************************************************************/
  597. /*************************************************************************/
  598. /*************************************************************************/
  599. /* This hook is used by the TrueType debugger. It must be set to an */
  600. /* alternate truetype bytecode interpreter function. */
  601. #define FT_DEBUG_HOOK_TRUETYPE 0
  602. /* Set this debug hook to a non-null pointer to force unpatented hinting */
  603. /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */
  604. /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */
  605. /* during debugging. */
  606. #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1
  607. typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
  608. FT_Render_Mode render_mode,
  609. FT_Library library );
  610. /*************************************************************************/
  611. /* */
  612. /* <Struct> */
  613. /* FT_LibraryRec */
  614. /* */
  615. /* <Description> */
  616. /* The FreeType library class. This is the root of all FreeType */
  617. /* data. Use FT_New_Library() to create a library object, and */
  618. /* FT_Done_Library() to discard it and all child objects. */
  619. /* */
  620. /* <Fields> */
  621. /* memory :: The library's memory object. Manages memory */
  622. /* allocation. */
  623. /* */
  624. /* version_major :: The major version number of the library. */
  625. /* */
  626. /* version_minor :: The minor version number of the library. */
  627. /* */
  628. /* version_patch :: The current patch level of the library. */
  629. /* */
  630. /* num_modules :: The number of modules currently registered */
  631. /* within this library. This is set to 0 for new */
  632. /* libraries. New modules are added through the */
  633. /* FT_Add_Module() API function. */
  634. /* */
  635. /* modules :: A table used to store handles to the currently */
  636. /* registered modules. Note that each font driver */
  637. /* contains a list of its opened faces. */
  638. /* */
  639. /* renderers :: The list of renderers currently registered */
  640. /* within the library. */
  641. /* */
  642. /* cur_renderer :: The current outline renderer. This is a */
  643. /* shortcut used to avoid parsing the list on */
  644. /* each call to FT_Outline_Render(). It is a */
  645. /* handle to the current renderer for the */
  646. /* FT_GLYPH_FORMAT_OUTLINE format. */
  647. /* */
  648. /* auto_hinter :: XXX */
  649. /* */
  650. /* raster_pool :: The raster object's render pool. This can */
  651. /* ideally be changed dynamically at run-time. */
  652. /* */
  653. /* raster_pool_size :: The size of the render pool in bytes. */
  654. /* */
  655. /* debug_hooks :: XXX */
  656. /* */
  657. /* lcd_filter :: If subpixel rendering is activated, the */
  658. /* selected LCD filter mode. */
  659. /* */
  660. /* lcd_extra :: If subpixel rendering is activated, the number */
  661. /* of extra pixels needed for the LCD filter. */
  662. /* */
  663. /* lcd_weights :: If subpixel rendering is activated, the LCD */
  664. /* filter weights, if any. */
  665. /* */
  666. /* lcd_filter_func :: If subpixel rendering is activated, the LCD */
  667. /* filtering callback function. */
  668. /* */
  669. /* pic_container :: Contains global structs and tables, instead */
  670. /* of defining them globallly. */
  671. /* */
  672. /* refcount :: A counter initialized to~1 at the time an */
  673. /* @FT_Library structure is created. */
  674. /* @FT_Reference_Library increments this counter, */
  675. /* and @FT_Done_Library only destroys a library */
  676. /* if the counter is~1, otherwise it simply */
  677. /* decrements it. */
  678. /* */
  679. typedef struct FT_LibraryRec_
  680. {
  681. FT_Memory memory; /* library's memory manager */
  682. FT_Int version_major;
  683. FT_Int version_minor;
  684. FT_Int version_patch;
  685. FT_UInt num_modules;
  686. FT_Module modules[FT_MAX_MODULES]; /* module objects */
  687. FT_ListRec renderers; /* list of renderers */
  688. FT_Renderer cur_renderer; /* current outline renderer */
  689. FT_Module auto_hinter;
  690. FT_Byte* raster_pool; /* scan-line conversion */
  691. /* render pool */
  692. FT_ULong raster_pool_size; /* size of render pool in bytes */
  693. FT_DebugHook_Func debug_hooks[4];
  694. #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
  695. FT_LcdFilter lcd_filter;
  696. FT_Int lcd_extra; /* number of extra pixels */
  697. FT_Byte lcd_weights[7]; /* filter weights, if any */
  698. FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
  699. #endif
  700. #ifdef FT_CONFIG_OPTION_PIC
  701. FT_PIC_Container pic_container;
  702. #endif
  703. FT_UInt refcount;
  704. } FT_LibraryRec;
  705. FT_BASE( FT_Renderer )
  706. FT_Lookup_Renderer( FT_Library library,
  707. FT_Glyph_Format format,
  708. FT_ListNode* node );
  709. FT_BASE( FT_Error )
  710. FT_Render_Glyph_Internal( FT_Library library,
  711. FT_GlyphSlot slot,
  712. FT_Render_Mode render_mode );
  713. typedef const char*
  714. (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
  715. typedef FT_Error
  716. (*FT_Face_GetGlyphNameFunc)( FT_Face face,
  717. FT_UInt glyph_index,
  718. FT_Pointer buffer,
  719. FT_UInt buffer_max );
  720. typedef FT_UInt
  721. (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
  722. FT_String* glyph_name );
  723. #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
  724. /*************************************************************************/
  725. /* */
  726. /* <Function> */
  727. /* FT_New_Memory */
  728. /* */
  729. /* <Description> */
  730. /* Creates a new memory object. */
  731. /* */
  732. /* <Return> */
  733. /* A pointer to the new memory object. 0 in case of error. */
  734. /* */
  735. FT_BASE( FT_Memory )
  736. FT_New_Memory( void );
  737. /*************************************************************************/
  738. /* */
  739. /* <Function> */
  740. /* FT_Done_Memory */
  741. /* */
  742. /* <Description> */
  743. /* Discards memory manager. */
  744. /* */
  745. /* <Input> */
  746. /* memory :: A handle to the memory manager. */
  747. /* */
  748. FT_BASE( void )
  749. FT_Done_Memory( FT_Memory memory );
  750. #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
  751. /* Define default raster's interface. The default raster is located in */
  752. /* `src/base/ftraster.c'. */
  753. /* */
  754. /* Client applications can register new rasters through the */
  755. /* FT_Set_Raster() API. */
  756. #ifndef FT_NO_DEFAULT_RASTER
  757. FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
  758. #endif
  759. /*************************************************************************/
  760. /*************************************************************************/
  761. /*************************************************************************/
  762. /**** ****/
  763. /**** ****/
  764. /**** PIC-Support Macros for ftimage.h ****/
  765. /**** ****/
  766. /**** ****/
  767. /*************************************************************************/
  768. /*************************************************************************/
  769. /*************************************************************************/
  770. /*************************************************************************/
  771. /* */
  772. /* <Macro> */
  773. /* FT_DEFINE_OUTLINE_FUNCS */
  774. /* */
  775. /* <Description> */
  776. /* Used to initialize an instance of FT_Outline_Funcs struct. */
  777. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  778. /* called with a pre-allocated stracture to be filled. */
  779. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  780. /* allocated in the global scope (or the scope where the macro */
  781. /* is used). */
  782. /* */
  783. #ifndef FT_CONFIG_OPTION_PIC
  784. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  785. cubic_to_, shift_, delta_) \
  786. static const FT_Outline_Funcs class_ = \
  787. { \
  788. move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
  789. };
  790. #else /* FT_CONFIG_OPTION_PIC */
  791. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  792. cubic_to_, shift_, delta_) \
  793. static FT_Error \
  794. Init_Class_##class_( FT_Outline_Funcs* clazz ) \
  795. { \
  796. clazz->move_to = move_to_; \
  797. clazz->line_to = line_to_; \
  798. clazz->conic_to = conic_to_; \
  799. clazz->cubic_to = cubic_to_; \
  800. clazz->shift = shift_;