ftobjs.h 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  1. /***************************************************************************/
  2. /* */
  3. /* ftobjs.h */
  4. /* */
  5. /* The FreeType private base classes (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 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. /* generic :: A generic structure for user-level extensibility (?). */
  364. /* */
  365. typedef struct FT_ModuleRec_
  366. {
  367. FT_Module_Class* clazz;
  368. FT_Library library;
  369. FT_Memory memory;
  370. FT_Generic generic;
  371. } FT_ModuleRec;
  372. /* typecast an object to a FT_Module */
  373. #define FT_MODULE( x ) ((FT_Module)( x ))
  374. #define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
  375. #define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
  376. #define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
  377. #define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  378. FT_MODULE_FONT_DRIVER )
  379. #define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  380. FT_MODULE_RENDERER )
  381. #define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  382. FT_MODULE_HINTER )
  383. #define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  384. FT_MODULE_STYLER )
  385. #define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  386. FT_MODULE_DRIVER_SCALABLE )
  387. #define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
  388. FT_MODULE_DRIVER_NO_OUTLINES )
  389. #define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
  390. FT_MODULE_DRIVER_HAS_HINTER )
  391. /*************************************************************************/
  392. /* */
  393. /* <Function> */
  394. /* FT_Get_Module_Interface */
  395. /* */
  396. /* <Description> */
  397. /* Finds a module and returns its specific interface as a typeless */
  398. /* pointer. */
  399. /* */
  400. /* <Input> */
  401. /* library :: A handle to the library object. */
  402. /* */
  403. /* module_name :: The module's name (as an ASCII string). */
  404. /* */
  405. /* <Return> */
  406. /* A module-specific interface if available, 0 otherwise. */
  407. /* */
  408. /* <Note> */
  409. /* You should better be familiar with FreeType internals to know */
  410. /* which module to look for, and what its interface is :-) */
  411. /* */
  412. FT_BASE( const void* )
  413. FT_Get_Module_Interface( FT_Library library,
  414. const char* mod_name );
  415. FT_BASE( FT_Pointer )
  416. ft_module_get_service( FT_Module module,
  417. const char* service_id );
  418. /* */
  419. /*************************************************************************/
  420. /*************************************************************************/
  421. /*************************************************************************/
  422. /**** ****/
  423. /**** ****/
  424. /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
  425. /**** ****/
  426. /**** ****/
  427. /*************************************************************************/
  428. /*************************************************************************/
  429. /*************************************************************************/
  430. /* a few macros used to perform easy typecasts with minimal brain damage */
  431. #define FT_FACE( x ) ((FT_Face)(x))
  432. #define FT_SIZE( x ) ((FT_Size)(x))
  433. #define FT_SLOT( x ) ((FT_GlyphSlot)(x))
  434. #define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
  435. #define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
  436. #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
  437. #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
  438. #define FT_SIZE_FACE( x ) FT_SIZE( x )->face
  439. #define FT_SLOT_FACE( x ) FT_SLOT( x )->face
  440. #define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
  441. #define FT_FACE_SIZE( x ) FT_FACE( x )->size
  442. /*************************************************************************/
  443. /* */
  444. /* <Function> */
  445. /* FT_New_GlyphSlot */
  446. /* */
  447. /* <Description> */
  448. /* It is sometimes useful to have more than one glyph slot for a */
  449. /* given face object. This function is used to create additional */
  450. /* slots. All of them are automatically discarded when the face is */
  451. /* destroyed. */
  452. /* */
  453. /* <Input> */
  454. /* face :: A handle to a parent face object. */
  455. /* */
  456. /* <Output> */
  457. /* aslot :: A handle to a new glyph slot object. */
  458. /* */
  459. /* <Return> */
  460. /* FreeType error code. 0 means success. */
  461. /* */
  462. FT_BASE( FT_Error )
  463. FT_New_GlyphSlot( FT_Face face,
  464. FT_GlyphSlot *aslot );
  465. /*************************************************************************/
  466. /* */
  467. /* <Function> */
  468. /* FT_Done_GlyphSlot */
  469. /* */
  470. /* <Description> */
  471. /* Destroys a given glyph slot. Remember however that all slots are */
  472. /* automatically destroyed with its parent. Using this function is */
  473. /* not always mandatory. */
  474. /* */
  475. /* <Input> */
  476. /* slot :: A handle to a target glyph slot. */
  477. /* */
  478. FT_BASE( void )
  479. FT_Done_GlyphSlot( FT_GlyphSlot slot );
  480. /* */
  481. #define FT_REQUEST_WIDTH( req ) \
  482. ( (req)->horiResolution \
  483. ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
  484. : (req)->width )
  485. #define FT_REQUEST_HEIGHT( req ) \
  486. ( (req)->vertResolution \
  487. ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
  488. : (req)->height )
  489. /* Set the metrics according to a bitmap strike. */
  490. FT_BASE( void )
  491. FT_Select_Metrics( FT_Face face,
  492. FT_ULong strike_index );
  493. /* Set the metrics according to a size request. */
  494. FT_BASE( void )
  495. FT_Request_Metrics( FT_Face face,
  496. FT_Size_Request req );
  497. /* Match a size request against `available_sizes'. */
  498. FT_BASE( FT_Error )
  499. FT_Match_Size( FT_Face face,
  500. FT_Size_Request req,
  501. FT_Bool ignore_width,
  502. FT_ULong* size_index );
  503. /* Use the horizontal metrics to synthesize the vertical metrics. */
  504. /* If `advance' is zero, it is also synthesized. */
  505. FT_BASE( void )
  506. ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
  507. FT_Pos advance );
  508. /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
  509. /* was allocated with ft_glyphslot_alloc_bitmap). */
  510. FT_BASE( void )
  511. ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
  512. /* Allocate a new bitmap buffer in a glyph slot. */
  513. FT_BASE( FT_Error )
  514. ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
  515. FT_ULong size );
  516. /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
  517. /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
  518. FT_BASE( void )
  519. ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
  520. FT_Byte* buffer );
  521. /*************************************************************************/
  522. /*************************************************************************/
  523. /*************************************************************************/
  524. /**** ****/
  525. /**** ****/
  526. /**** R E N D E R E R S ****/
  527. /**** ****/
  528. /**** ****/
  529. /*************************************************************************/
  530. /*************************************************************************/
  531. /*************************************************************************/
  532. #define FT_RENDERER( x ) ((FT_Renderer)( x ))
  533. #define FT_GLYPH( x ) ((FT_Glyph)( x ))
  534. #define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
  535. #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
  536. typedef struct FT_RendererRec_
  537. {
  538. FT_ModuleRec root;
  539. FT_Renderer_Class* clazz;
  540. FT_Glyph_Format glyph_format;
  541. FT_Glyph_Class glyph_class;
  542. FT_Raster raster;
  543. FT_Raster_Render_Func raster_render;
  544. FT_Renderer_RenderFunc render;
  545. } FT_RendererRec;
  546. /*************************************************************************/
  547. /*************************************************************************/
  548. /*************************************************************************/
  549. /**** ****/
  550. /**** ****/
  551. /**** F O N T D R I V E R S ****/
  552. /**** ****/
  553. /**** ****/
  554. /*************************************************************************/
  555. /*************************************************************************/
  556. /*************************************************************************/
  557. /* typecast a module into a driver easily */
  558. #define FT_DRIVER( x ) ((FT_Driver)(x))
  559. /* typecast a module as a driver, and get its driver class */
  560. #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
  561. /*************************************************************************/
  562. /* */
  563. /* <Struct> */
  564. /* FT_DriverRec */
  565. /* */
  566. /* <Description> */
  567. /* The root font driver class. A font driver is responsible for */
  568. /* managing and loading font files of a given format. */
  569. /* */
  570. /* <Fields> */
  571. /* root :: Contains the fields of the root module class. */
  572. /* */
  573. /* clazz :: A pointer to the font driver's class. Note that */
  574. /* this is NOT root.clazz. `class' wasn't used */
  575. /* as it is a reserved word in C++. */
  576. /* */
  577. /* faces_list :: The list of faces currently opened by this */
  578. /* driver. */
  579. /* */
  580. /* extensions :: A typeless pointer to the driver's extensions */
  581. /* registry, if they are supported through the */
  582. /* configuration macro FT_CONFIG_OPTION_EXTENSIONS. */
  583. /* */
  584. /* glyph_loader :: The glyph loader for all faces managed by this */
  585. /* driver. This object isn't defined for unscalable */
  586. /* formats. */
  587. /* */
  588. typedef struct FT_DriverRec_
  589. {
  590. FT_ModuleRec root;
  591. FT_Driver_Class clazz;
  592. FT_ListRec faces_list;
  593. void* extensions;
  594. FT_GlyphLoader glyph_loader;
  595. } FT_DriverRec;
  596. /*************************************************************************/
  597. /*************************************************************************/
  598. /*************************************************************************/
  599. /**** ****/
  600. /**** ****/
  601. /**** L I B R A R I E S ****/
  602. /**** ****/
  603. /**** ****/
  604. /*************************************************************************/
  605. /*************************************************************************/
  606. /*************************************************************************/
  607. /* This hook is used by the TrueType debugger. It must be set to an */
  608. /* alternate truetype bytecode interpreter function. */
  609. #define FT_DEBUG_HOOK_TRUETYPE 0
  610. /* Set this debug hook to a non-null pointer to force unpatented hinting */
  611. /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */
  612. /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */
  613. /* during debugging. */
  614. #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1
  615. typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
  616. FT_Render_Mode render_mode,
  617. FT_Library library );
  618. /*************************************************************************/
  619. /* */
  620. /* <Struct> */
  621. /* FT_LibraryRec */
  622. /* */
  623. /* <Description> */
  624. /* The FreeType library class. This is the root of all FreeType */
  625. /* data. Use FT_New_Library() to create a library object, and */
  626. /* FT_Done_Library() to discard it and all child objects. */
  627. /* */
  628. /* <Fields> */
  629. /* memory :: The library's memory object. Manages memory */
  630. /* allocation. */
  631. /* */
  632. /* generic :: Client data variable. Used to extend the */
  633. /* Library class by higher levels and clients. */
  634. /* */
  635. /* version_major :: The major version number of the library. */
  636. /* */
  637. /* version_minor :: The minor version number of the library. */
  638. /* */
  639. /* version_patch :: The current patch level of the library. */
  640. /* */
  641. /* num_modules :: The number of modules currently registered */
  642. /* within this library. This is set to 0 for new */
  643. /* libraries. New modules are added through the */
  644. /* FT_Add_Module() API function. */
  645. /* */
  646. /* modules :: A table used to store handles to the currently */
  647. /* registered modules. Note that each font driver */
  648. /* contains a list of its opened faces. */
  649. /* */
  650. /* renderers :: The list of renderers currently registered */
  651. /* within the library. */
  652. /* */
  653. /* cur_renderer :: The current outline renderer. This is a */
  654. /* shortcut used to avoid parsing the list on */
  655. /* each call to FT_Outline_Render(). It is a */
  656. /* handle to the current renderer for the */
  657. /* FT_GLYPH_FORMAT_OUTLINE format. */
  658. /* */
  659. /* auto_hinter :: XXX */
  660. /* */
  661. /* raster_pool :: The raster object's render pool. This can */
  662. /* ideally be changed dynamically at run-time. */
  663. /* */
  664. /* raster_pool_size :: The size of the render pool in bytes. */
  665. /* */
  666. /* debug_hooks :: XXX */
  667. /* */
  668. /* lcd_filter :: If subpixel rendering is activated, the */
  669. /* selected LCD filter mode. */
  670. /* */
  671. /* lcd_extra :: If subpixel rendering is activated, the number */
  672. /* of extra pixels needed for the LCD filter. */
  673. /* */
  674. /* lcd_weights :: If subpixel rendering is activated, the LCD */
  675. /* filter weights, if any. */
  676. /* */
  677. /* lcd_filter_func :: If subpixel rendering is activated, the LCD */
  678. /* filtering callback function. */
  679. /* */
  680. /* pic_container :: Contains global structs and tables, instead */
  681. /* of defining them globallly. */
  682. /* */
  683. /* refcount :: A counter initialized to~1 at the time an */
  684. /* @FT_Library structure is created. */
  685. /* @FT_Reference_Library increments this counter, */
  686. /* and @FT_Done_Library only destroys a library */
  687. /* if the counter is~1, otherwise it simply */
  688. /* decrements it. */
  689. /* */
  690. typedef struct FT_LibraryRec_
  691. {
  692. FT_Memory memory; /* library's memory manager */
  693. FT_Generic generic;
  694. FT_Int version_major;
  695. FT_Int version_minor;
  696. FT_Int version_patch;
  697. FT_UInt num_modules;
  698. FT_Module modules[FT_MAX_MODULES]; /* module objects */
  699. FT_ListRec renderers; /* list of renderers */
  700. FT_Renderer cur_renderer; /* current outline renderer */
  701. FT_Module auto_hinter;
  702. FT_Byte* raster_pool; /* scan-line conversion */
  703. /* render pool */
  704. FT_ULong raster_pool_size; /* size of render pool in bytes */
  705. FT_DebugHook_Func debug_hooks[4];
  706. #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
  707. FT_LcdFilter lcd_filter;
  708. FT_Int lcd_extra; /* number of extra pixels */
  709. FT_Byte lcd_weights[7]; /* filter weights, if any */
  710. FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
  711. #endif
  712. #ifdef FT_CONFIG_OPTION_PIC
  713. FT_PIC_Container pic_container;
  714. #endif
  715. FT_UInt refcount;
  716. } FT_LibraryRec;
  717. FT_BASE( FT_Renderer )
  718. FT_Lookup_Renderer( FT_Library library,
  719. FT_Glyph_Format format,
  720. FT_ListNode* node );
  721. FT_BASE( FT_Error )
  722. FT_Render_Glyph_Internal( FT_Library library,
  723. FT_GlyphSlot slot,
  724. FT_Render_Mode render_mode );
  725. typedef const char*
  726. (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
  727. typedef FT_Error
  728. (*FT_Face_GetGlyphNameFunc)( FT_Face face,
  729. FT_UInt glyph_index,
  730. FT_Pointer buffer,
  731. FT_UInt buffer_max );
  732. typedef FT_UInt
  733. (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
  734. FT_String* glyph_name );
  735. #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
  736. /*************************************************************************/
  737. /* */
  738. /* <Function> */
  739. /* FT_New_Memory */
  740. /* */
  741. /* <Description> */
  742. /* Creates a new memory object. */
  743. /* */
  744. /* <Return> */
  745. /* A pointer to the new memory object. 0 in case of error. */
  746. /* */
  747. FT_BASE( FT_Memory )
  748. FT_New_Memory( void );
  749. /*************************************************************************/
  750. /* */
  751. /* <Function> */
  752. /* FT_Done_Memory */
  753. /* */
  754. /* <Description> */
  755. /* Discards memory manager. */
  756. /* */
  757. /* <Input> */
  758. /* memory :: A handle to the memory manager. */
  759. /* */
  760. FT_BASE( void )
  761. FT_Done_Memory( FT_Memory memory );
  762. #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
  763. /* Define default raster's interface. The default raster is located in */
  764. /* `src/base/ftraster.c'. */
  765. /* */
  766. /* Client applications can register new rasters through the */
  767. /* FT_Set_Raster() API. */
  768. #ifndef FT_NO_DEFAULT_RASTER
  769. FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
  770. #endif
  771. /*************************************************************************/
  772. /*************************************************************************/
  773. /*************************************************************************/
  774. /**** ****/
  775. /**** ****/
  776. /**** PIC-Support Macros for ftimage.h ****/
  777. /**** ****/
  778. /**** ****/
  779. /*************************************************************************/
  780. /*************************************************************************/
  781. /*************************************************************************/
  782. /*************************************************************************/
  783. /* */
  784. /* <Macro> */
  785. /* FT_DEFINE_OUTLINE_FUNCS */
  786. /* */
  787. /* <Description> */
  788. /* Used to initialize an instance of FT_Outline_Funcs struct. */
  789. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  790. /* called with a pre-allocated stracture to be filled. */
  791. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  792. /* allocated in the global scope (or the scope where the macro */
  793. /* is used). */
  794. /* */
  795. #ifndef FT_CONFIG_OPTION_PIC
  796. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  797. cubic_to_, shift_, delta_) \
  798. static const FT_Outline_Funcs class_ = \
  799. { \
  800. move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
  801. };
  802. #else /* FT_CONFIG_OPTION_PIC */
  803. #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
  804. cubic_to_, shift_, delta_) \
  805. static FT_Error \
  806. Init_Class_##class_( FT_Outline_Funcs* clazz ) \
  807. { \
  808. clazz->move_to = move_to_; \
  809. clazz->line_to = line_to_; \
  810. clazz->conic_to = conic_to_; \
  811. clazz->cubic_to = cubic_to_; \
  812. clazz->shift = shift_; \
  813. clazz->delta = delta_; \
  814. return FT_Err_Ok; \
  815. }
  816. #endif /* FT_CONFIG_OPTION_PIC */
  817. /*************************************************************************/
  818. /* */
  819. /* <Macro> */
  820. /* FT_DEFINE_RASTER_FUNCS */
  821. /* */
  822. /* <Description> */
  823. /* Used to initialize an instance of FT_Raster_Funcs struct. */
  824. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  825. /* called with a pre-allocated stracture to be filled. */
  826. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  827. /* allocated in the global scope (or the scope where the macro */
  828. /* is used). */
  829. /* */
  830. #ifndef FT_CONFIG_OPTION_PIC
  831. #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
  832. raster_reset_, raster_set_mode_, \
  833. raster_render_, raster_done_) \
  834. const FT_Raster_Funcs class_ = \
  835. { \
  836. glyph_format_, raster_new_, raster_reset_, \
  837. raster_set_mode_, raster_render_, raster_done_ \
  838. };
  839. #else /* FT_CONFIG_OPTION_PIC */
  840. #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
  841. raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
  842. void \
  843. FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
  844. { \
  845. clazz->glyph_format = glyph_format_; \
  846. clazz->raster_new = raster_new_; \
  847. clazz->raster_reset = raster_reset_; \
  848. clazz->raster_set_mode = raster_set_mode_; \
  849. clazz->raster_render = raster_render_; \
  850. clazz->raster_done = raster_done_; \
  851. }
  852. #endif /* FT_CONFIG_OPTION_PIC */
  853. /*************************************************************************/
  854. /*************************************************************************/
  855. /*************************************************************************/
  856. /**** ****/
  857. /**** ****/
  858. /**** PIC-Support Macros for ftrender.h ****/
  859. /**** ****/
  860. /**** ****/
  861. /*************************************************************************/
  862. /*************************************************************************/
  863. /*************************************************************************/
  864. /*************************************************************************/
  865. /* */
  866. /* <Macro> */
  867. /* FT_DEFINE_GLYPH */
  868. /* */
  869. /* <Description> */
  870. /* Used to initialize an instance of FT_Glyph_Class struct. */
  871. /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
  872. /* called with a pre-allocated stracture to be filled. */
  873. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  874. /* allocated in the global scope (or the scope where the macro */
  875. /* is used). */
  876. /* */
  877. #ifndef FT_CONFIG_OPTION_PIC
  878. #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
  879. transform_, bbox_, prepare_) \
  880. FT_CALLBACK_TABLE_DEF \
  881. const FT_Glyph_Class class_ = \
  882. { \
  883. size_, format_, init_, done_, copy_, transform_, bbox_, prepare_ \
  884. };
  885. #else /* FT_CONFIG_OPTION_PIC */
  886. #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
  887. transform_, bbox_, prepare_) \
  888. void \
  889. FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
  890. { \
  891. clazz->glyph_size = size_; \
  892. clazz->glyph_format = format_; \
  893. clazz->glyph_init = init_; \
  894. clazz->glyph_done = done_; \
  895. clazz->glyph_copy = copy_; \
  896. clazz->glyph_transform = transform_; \
  897. clazz->glyph_bbox = bbox_; \
  898. clazz->glyph_prepare = prepare_; \
  899. }
  900. #endif /* FT_CONFIG_OPTION_PIC */
  901. /*************************************************************************/
  902. /* */
  903. /* <Macro> */
  904. /* FT_DECLARE_RENDERER */
  905. /* */
  906. /* <Description> */
  907. /* Used to create a forward declaration of a */
  908. /* FT_Renderer_Class stract instance. */
  909. /* */
  910. /* <Macro> */
  911. /* FT_DEFINE_RENDERER */
  912. /* */
  913. /* <Description> */
  914. /* Used to initialize an instance of FT_Renderer_Class struct. */
  915. /* */
  916. /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
  917. /* to called with a pointer where the allocated stracture is returned.*/
  918. /* And when it is no longer needed a Destroy function needs */
  919. /* to be called to release that allocation. */
  920. /* fcinit.c (ft_create_default_module_classes) already contains */
  921. /* a mechanism to call these functions for the default modules */
  922. /* described in ftmodule.h */
  923. /* */
  924. /* Notice that the created Create and Destroy functions call */
  925. /* pic_init and pic_free function to allow you to manually allocate */
  926. /* and initialize any additional global data, like module specific */
  927. /* interface, and put them in the global pic container defined in */
  928. /* ftpic.h. if you don't need them just implement the functions as */
  929. /* empty to resolve the link error. */
  930. /* */
  931. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  932. /* allocated in the global scope (or the scope where the macro */
  933. /* is used). */
  934. /* */
  935. #ifndef FT_CONFIG_OPTION_PIC
  936. #define FT_DECLARE_RENDERER(class_) \
  937. FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
  938. #define FT_DEFINE_RENDERER(class_, \
  939. flags_, size_, name_, version_, requires_, \
  940. interface_, init_, done_, get_interface_, \
  941. glyph_format_, render_glyph_, transform_glyph_, \
  942. get_glyph_cbox_, set_mode_, raster_class_ ) \
  943. FT_CALLBACK_TABLE_DEF \
  944. const FT_Renderer_Class class_ = \
  945. { \
  946. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
  947. interface_,init_,done_,get_interface_) \
  948. glyph_format_, \
  949. \
  950. render_glyph_, \
  951. transform_glyph_, \
  952. get_glyph_cbox_, \
  953. set_mode_, \
  954. \
  955. raster_class_ \
  956. };
  957. #else /* FT_CONFIG_OPTION_PIC */
  958. #define FT_DECLARE_RENDERER(class_) FT_DECLARE_MODULE(class_)
  959. #define FT_DEFINE_RENDERER(class_, \
  960. flags_, size_, name_, version_, requires_, \
  961. interface_, init_, done_, get_interface_, \
  962. glyph_format_, render_glyph_, transform_glyph_, \
  963. get_glyph_cbox_, set_mode_, raster_class_ ) \
  964. void class_##_pic_free( FT_Library library ); \
  965. FT_Error class_##_pic_init( FT_Library library ); \
  966. \
  967. void \
  968. FT_Destroy_Class_##class_( FT_Library library, \
  969. FT_Module_Class* clazz ) \
  970. { \
  971. FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
  972. FT_Memory memory = library->memory; \
  973. class_##_pic_free( library ); \
  974. if ( rclazz ) \
  975. FT_FREE( rclazz ); \
  976. } \
  977. \
  978. FT_Error \
  979. FT_Create_Class_##class_( FT_Library library, \
  980. FT_Module_Class** output_class ) \
  981. { \
  982. FT_Renderer_Class* clazz; \
  983. FT_Error error; \
  984. FT_Memory memory = library->memory; \
  985. \
  986. if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
  987. return error; \
  988. \
  989. error = class_##_pic_init( library ); \
  990. if(error) \
  991. { \
  992. FT_FREE( clazz ); \
  993. return error; \
  994. } \
  995. \
  996. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
  997. interface_,init_,done_,get_interface_) \
  998. \
  999. clazz->glyph_format = glyph_format_; \
  1000. \
  1001. clazz->render_glyph = render_glyph_; \
  1002. clazz->transform_glyph = transform_glyph_; \
  1003. clazz->get_glyph_cbox = get_glyph_cbox_; \
  1004. clazz->set_mode = set_mode_; \
  1005. \
  1006. clazz->raster_class = raster_class_; \
  1007. \
  1008. *output_class = (FT_Module_Class*)clazz; \
  1009. return FT_Err_Ok; \
  1010. }
  1011. #endif /* FT_CONFIG_OPTION_PIC */
  1012. /*************************************************************************/
  1013. /*************************************************************************/
  1014. /*************************************************************************/
  1015. /**** ****/
  1016. /**** ****/
  1017. /**** PIC-Support Macros for ftmodapi.h ****/
  1018. /**** ****/
  1019. /**** ****/
  1020. /*************************************************************************/
  1021. /*************************************************************************/
  1022. /*************************************************************************/
  1023. #ifdef FT_CONFIG_OPTION_PIC
  1024. /*************************************************************************/
  1025. /* */
  1026. /* <FuncType> */
  1027. /* FT_Module_Creator */
  1028. /* */
  1029. /* <Description> */
  1030. /* A function used to create (allocate) a new module class object. */
  1031. /* The object's members are initialized, but the module itself is */
  1032. /* not. */
  1033. /* */
  1034. /* <Input> */
  1035. /* memory :: A handle to the memory manager. */
  1036. /* output_class :: Initialized with the newly allocated class. */
  1037. /* */
  1038. typedef FT_Error
  1039. (*FT_Module_Creator)( FT_Memory memory,
  1040. FT_Module_Class** output_class );
  1041. /*************************************************************************/
  1042. /* */
  1043. /* <FuncType> */
  1044. /* FT_Module_Destroyer */
  1045. /* */
  1046. /* <Description> */
  1047. /* A function used to destroy (deallocate) a module class object. */
  1048. /* */
  1049. /* <Input> */
  1050. /* memory :: A handle to the memory manager. */
  1051. /* clazz :: Module class to destroy. */
  1052. /* */
  1053. typedef void
  1054. (*FT_Module_Destroyer)( FT_Memory memory,
  1055. FT_Module_Class* clazz );
  1056. #endif
  1057. /*************************************************************************/
  1058. /* */
  1059. /* <Macro> */
  1060. /* FT_DECLARE_MODULE */
  1061. /* */
  1062. /* <Description> */
  1063. /* Used to create a forward declaration of a */
  1064. /* FT_Module_Class stract instance. */
  1065. /* */
  1066. /* <Macro> */
  1067. /* FT_DEFINE_MODULE */
  1068. /* */
  1069. /* <Description> */
  1070. /* Used to initialize an instance of FT_Module_Class struct. */
  1071. /* */
  1072. /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
  1073. /* to called with a pointer where the allocated stracture is returned.*/
  1074. /* And when it is no longer needed a Destroy function needs */
  1075. /* to be called to release that allocation. */
  1076. /* fcinit.c (ft_create_default_module_classes) already contains */
  1077. /* a mechanism to call these functions for the default modules */
  1078. /* described in ftmodule.h */
  1079. /* */
  1080. /* Notice that the created Create and Destroy functions call */
  1081. /* pic_init and pic_free function to allow you to manually allocate */
  1082. /* and initialize any additional global data, like module specific */
  1083. /* interface, and put them in the global pic container defined in */
  1084. /* ftpic.h. if you don't need them just implement the functions as */
  1085. /* empty to resolve the link error. */
  1086. /* */
  1087. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  1088. /* allocated in the global scope (or the scope where the macro */
  1089. /* is used). */
  1090. /* */
  1091. /* <Macro> */
  1092. /* FT_DEFINE_ROOT_MODULE */
  1093. /* */
  1094. /* <Description> */
  1095. /* Used to initialize an instance of FT_Module_Class struct inside */
  1096. /* another stract that contains it or in a function that initializes */
  1097. /* that containing stract */
  1098. /* */
  1099. #ifndef FT_CONFIG_OPTION_PIC
  1100. #define FT_DECLARE_MODULE(class_) \
  1101. FT_CALLBACK_TABLE \
  1102. const FT_Module_Class class_; \
  1103. #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
  1104. interface_, init_, done_, get_interface_) \
  1105. { \
  1106. flags_, \
  1107. size_, \
  1108. \
  1109. name_, \
  1110. version_, \
  1111. requires_, \
  1112. \
  1113. interface_, \
  1114. \
  1115. init_, \
  1116. done_, \
  1117. get_interface_, \
  1118. },
  1119. #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
  1120. interface_, init_, done_, get_interface_) \
  1121. FT_CALLBACK_TABLE_DEF \
  1122. const FT_Module_Class class_ = \
  1123. { \
  1124. flags_, \
  1125. size_, \
  1126. \
  1127. name_, \
  1128. version_, \
  1129. requires_, \
  1130. \
  1131. interface_, \
  1132. \
  1133. init_, \
  1134. done_, \
  1135. get_interface_, \
  1136. };
  1137. #else /* FT_CONFIG_OPTION_PIC */
  1138. #define FT_DECLARE_MODULE(class_) \
  1139. FT_Error FT_Create_Class_##class_( FT_Library library, \
  1140. FT_Module_Class** output_class ); \
  1141. void FT_Destroy_Class_##class_( FT_Library library, \
  1142. FT_Module_Class* clazz );
  1143. #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
  1144. interface_, init_, done_, get_interface_) \
  1145. clazz->root.module_flags = flags_; \
  1146. clazz->root.module_size = size_; \
  1147. clazz->root.module_name = name_; \
  1148. clazz->root.module_version = version_; \
  1149. clazz->root.module_requires = requires_; \
  1150. \
  1151. clazz->root.module_interface = interface_; \
  1152. \
  1153. clazz->root.module_init = init_; \
  1154. clazz->root.module_done = done_; \
  1155. clazz->root.get_interface = get_interface_;
  1156. #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
  1157. interface_, init_, done_, get_interface_) \
  1158. void class_##_pic_free( FT_Library library ); \
  1159. FT_Error class_##_pic_init( FT_Library library ); \
  1160. \
  1161. void \
  1162. FT_Destroy_Class_##class_( FT_Library library, \
  1163. FT_Module_Class* clazz ) \
  1164. { \
  1165. FT_Memory memory = library->memory; \
  1166. class_##_pic_free( library ); \
  1167. if ( clazz ) \
  1168. FT_FREE( clazz ); \
  1169. } \
  1170. \
  1171. FT_Error \
  1172. FT_Create_Class_##class_( FT_Library library, \
  1173. FT_Module_Class** output_class ) \
  1174. { \
  1175. FT_Memory memory = library->memory; \
  1176. FT_Module_Class* clazz; \
  1177. FT_Error error; \
  1178. \
  1179. if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
  1180. return error; \
  1181. error = class_##_pic_init( library ); \
  1182. if(error) \
  1183. { \
  1184. FT_FREE( clazz ); \
  1185. return error; \
  1186. } \
  1187. \
  1188. clazz->module_flags = flags_; \
  1189. clazz->module_size = size_; \
  1190. clazz->module_name = name_; \
  1191. clazz->module_version = version_; \
  1192. clazz->module_requires = requires_; \
  1193. \
  1194. clazz->module_interface = interface_; \
  1195. \
  1196. clazz->module_init = init_; \
  1197. clazz->module_done = done_; \
  1198. clazz->get_interface = get_interface_; \
  1199. \
  1200. *output_class = clazz; \
  1201. return FT_Err_Ok; \
  1202. }
  1203. #endif /* FT_CONFIG_OPTION_PIC */
  1204. FT_END_HEADER
  1205. #endif /* __FTOBJS_H__ */
  1206. /* END */