/src/freetype/include/freetype/internal/ftdriver.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 421 lines · 229 code · 64 blank · 128 comment · 3 complexity · f63e6e42e6817a7338bec333aab5ce48 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftdriver.h */
  4. /* */
  5. /* FreeType font driver interface (specification). */
  6. /* */
  7. /* Copyright 1996-2003, 2006, 2008, 2011 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #ifndef __FTDRIVER_H__
  18. #define __FTDRIVER_H__
  19. #include <ft2build.h>
  20. #include FT_MODULE_H
  21. FT_BEGIN_HEADER
  22. typedef FT_Error
  23. (*FT_Face_InitFunc)( FT_Stream stream,
  24. FT_Face face,
  25. FT_Int typeface_index,
  26. FT_Int num_params,
  27. FT_Parameter* parameters );
  28. typedef void
  29. (*FT_Face_DoneFunc)( FT_Face face );
  30. typedef FT_Error
  31. (*FT_Size_InitFunc)( FT_Size size );
  32. typedef void
  33. (*FT_Size_DoneFunc)( FT_Size size );
  34. typedef FT_Error
  35. (*FT_Slot_InitFunc)( FT_GlyphSlot slot );
  36. typedef void
  37. (*FT_Slot_DoneFunc)( FT_GlyphSlot slot );
  38. typedef FT_Error
  39. (*FT_Size_RequestFunc)( FT_Size size,
  40. FT_Size_Request req );
  41. typedef FT_Error
  42. (*FT_Size_SelectFunc)( FT_Size size,
  43. FT_ULong size_index );
  44. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  45. typedef FT_Error
  46. (*FT_Size_ResetPointsFunc)( FT_Size size,
  47. FT_F26Dot6 char_width,
  48. FT_F26Dot6 char_height,
  49. FT_UInt horz_resolution,
  50. FT_UInt vert_resolution );
  51. typedef FT_Error
  52. (*FT_Size_ResetPixelsFunc)( FT_Size size,
  53. FT_UInt pixel_width,
  54. FT_UInt pixel_height );
  55. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  56. typedef FT_Error
  57. (*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
  58. FT_Size size,
  59. FT_UInt glyph_index,
  60. FT_Int32 load_flags );
  61. typedef FT_UInt
  62. (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap,
  63. FT_Long charcode );
  64. typedef FT_Long
  65. (*FT_CharMap_CharNextFunc)( FT_CharMap charmap,
  66. FT_Long charcode );
  67. typedef FT_Error
  68. (*FT_Face_GetKerningFunc)( FT_Face face,
  69. FT_UInt left_glyph,
  70. FT_UInt right_glyph,
  71. FT_Vector* kerning );
  72. typedef FT_Error
  73. (*FT_Face_AttachFunc)( FT_Face face,
  74. FT_Stream stream );
  75. typedef FT_Error
  76. (*FT_Face_GetAdvancesFunc)( FT_Face face,
  77. FT_UInt first,
  78. FT_UInt count,
  79. FT_Int32 flags,
  80. FT_Fixed* advances );
  81. /*************************************************************************/
  82. /* */
  83. /* <Struct> */
  84. /* FT_Driver_ClassRec */
  85. /* */
  86. /* <Description> */
  87. /* The font driver class. This structure mostly contains pointers to */
  88. /* driver methods. */
  89. /* */
  90. /* <Fields> */
  91. /* root :: The parent module. */
  92. /* */
  93. /* face_object_size :: The size of a face object in bytes. */
  94. /* */
  95. /* size_object_size :: The size of a size object in bytes. */
  96. /* */
  97. /* slot_object_size :: The size of a glyph object in bytes. */
  98. /* */
  99. /* init_face :: The format-specific face constructor. */
  100. /* */
  101. /* done_face :: The format-specific face destructor. */
  102. /* */
  103. /* init_size :: The format-specific size constructor. */
  104. /* */
  105. /* done_size :: The format-specific size destructor. */
  106. /* */
  107. /* init_slot :: The format-specific slot constructor. */
  108. /* */
  109. /* done_slot :: The format-specific slot destructor. */
  110. /* */
  111. /* */
  112. /* load_glyph :: A function handle to load a glyph to a slot. */
  113. /* This field is mandatory! */
  114. /* */
  115. /* get_kerning :: A function handle to return the unscaled */
  116. /* kerning for a given pair of glyphs. Can be */
  117. /* set to 0 if the format doesn't support */
  118. /* kerning. */
  119. /* */
  120. /* attach_file :: This function handle is used to read */
  121. /* additional data for a face from another */
  122. /* file/stream. For example, this can be used to */
  123. /* add data from AFM or PFM files on a Type 1 */
  124. /* face, or a CIDMap on a CID-keyed face. */
  125. /* */
  126. /* get_advances :: A function handle used to return advance */
  127. /* widths of `count' glyphs (in font units), */
  128. /* starting at `first'. The `vertical' flag must */
  129. /* be set to get vertical advance heights. The */
  130. /* `advances' buffer is caller-allocated. */
  131. /* The idea of this function is to be able to */
  132. /* perform device-independent text layout without */
  133. /* loading a single glyph image. */
  134. /* */
  135. /* request_size :: A handle to a function used to request the new */
  136. /* character size. Can be set to 0 if the */
  137. /* scaling done in the base layer suffices. */
  138. /* */
  139. /* select_size :: A handle to a function used to select a new */
  140. /* fixed size. It is used only if */
  141. /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */
  142. /* to 0 if the scaling done in the base layer */
  143. /* suffices. */
  144. /* <Note> */
  145. /* Most function pointers, with the exception of `load_glyph', can be */
  146. /* set to 0 to indicate a default behaviour. */
  147. /* */
  148. typedef struct FT_Driver_ClassRec_
  149. {
  150. FT_Module_Class root;
  151. FT_Long face_object_size;
  152. FT_Long size_object_size;
  153. FT_Long slot_object_size;
  154. FT_Face_InitFunc init_face;
  155. FT_Face_DoneFunc done_face;
  156. FT_Size_InitFunc init_size;
  157. FT_Size_DoneFunc done_size;
  158. FT_Slot_InitFunc init_slot;
  159. FT_Slot_DoneFunc done_slot;
  160. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  161. FT_Size_ResetPointsFunc set_char_sizes;
  162. FT_Size_ResetPixelsFunc set_pixel_sizes;
  163. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  164. FT_Slot_LoadFunc load_glyph;
  165. FT_Face_GetKerningFunc get_kerning;
  166. FT_Face_AttachFunc attach_file;
  167. FT_Face_GetAdvancesFunc get_advances;
  168. /* since version 2.2 */
  169. FT_Size_RequestFunc request_size;
  170. FT_Size_SelectFunc select_size;
  171. } FT_Driver_ClassRec, *FT_Driver_Class;
  172. /*
  173. * The following functions are used as stubs for `set_char_sizes' and
  174. * `set_pixel_sizes'; the code uses `request_size' and `select_size'
  175. * functions instead.
  176. *
  177. * Implementation is in `src/base/ftobjs.c'.
  178. */
  179. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  180. FT_BASE( FT_Error )
  181. ft_stub_set_char_sizes( FT_Size size,
  182. FT_F26Dot6 width,
  183. FT_F26Dot6 height,
  184. FT_UInt horz_res,
  185. FT_UInt vert_res );
  186. FT_BASE( FT_Error )
  187. ft_stub_set_pixel_sizes( FT_Size size,
  188. FT_UInt width,
  189. FT_UInt height );
  190. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  191. /*************************************************************************/
  192. /* */
  193. /* <Macro> */
  194. /* FT_DECLARE_DRIVER */
  195. /* */
  196. /* <Description> */
  197. /* Used to create a forward declaration of a */
  198. /* FT_Driver_ClassRec stract instance. */
  199. /* */
  200. /* <Macro> */
  201. /* FT_DEFINE_DRIVER */
  202. /* */
  203. /* <Description> */
  204. /* Used to initialize an instance of FT_Driver_ClassRec struct. */
  205. /* */
  206. /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
  207. /* to called with a pointer where the allocated stracture is returned.*/
  208. /* And when it is no longer needed a Destroy function needs */
  209. /* to be called to release that allocation. */
  210. /* fcinit.c (ft_create_default_module_classes) already contains */
  211. /* a mechanism to call these functions for the default modules */
  212. /* described in ftmodule.h */
  213. /* */
  214. /* Notice that the created Create and Destroy functions call */
  215. /* pic_init and pic_free function to allow you to manually allocate */
  216. /* and initialize any additional global data, like module specific */
  217. /* interface, and put them in the global pic container defined in */
  218. /* ftpic.h. if you don't need them just implement the functions as */
  219. /* empty to resolve the link error. Also the pic_init and pic_free */
  220. /* functions should be declared in pic.h, to be referred by driver */
  221. /* definition calling FT_DEFINE_DRIVER() in following. */
  222. /* */
  223. /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
  224. /* allocated in the global scope (or the scope where the macro */
  225. /* is used). */
  226. /* */
  227. #ifndef FT_CONFIG_OPTION_PIC
  228. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  229. #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
  230. a_, b_,
  231. #else
  232. #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
  233. #endif
  234. #define FT_DECLARE_DRIVER(class_) \
  235. FT_CALLBACK_TABLE \
  236. const FT_Driver_ClassRec class_;
  237. #define FT_DEFINE_DRIVER(class_, \
  238. flags_, size_, name_, version_, requires_, \
  239. interface_, init_, done_, get_interface_, \
  240. face_object_size_, size_object_size_, \
  241. slot_object_size_, init_face_, done_face_, \
  242. init_size_, done_size_, init_slot_, done_slot_, \
  243. old_set_char_sizes_, old_set_pixel_sizes_, \
  244. load_glyph_, get_kerning_, attach_file_, \
  245. get_advances_, request_size_, select_size_ ) \
  246. FT_CALLBACK_TABLE_DEF \
  247. const FT_Driver_ClassRec class_ = \
  248. { \
  249. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
  250. init_,done_,get_interface_) \
  251. \
  252. face_object_size_, \
  253. size_object_size_, \
  254. slot_object_size_, \
  255. \
  256. init_face_, \
  257. done_face_, \
  258. \
  259. init_size_, \
  260. done_size_, \
  261. \
  262. init_slot_, \
  263. done_slot_, \
  264. \
  265. FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
  266. \
  267. load_glyph_, \
  268. \
  269. get_kerning_, \
  270. attach_file_, \
  271. get_advances_, \
  272. \
  273. request_size_, \
  274. select_size_ \
  275. };
  276. #else /* FT_CONFIG_OPTION_PIC */
  277. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  278. #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
  279. clazz->set_char_sizes = a_; \
  280. clazz->set_pixel_sizes = b_;
  281. #else
  282. #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
  283. #endif
  284. #define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_)
  285. #define FT_DEFINE_DRIVER(class_, \
  286. flags_, size_, name_, version_, requires_, \
  287. interface_, init_, done_, get_interface_, \
  288. face_object_size_, size_object_size_, \
  289. slot_object_size_, init_face_, done_face_, \
  290. init_size_, done_size_, init_slot_, done_slot_, \
  291. old_set_char_sizes_, old_set_pixel_sizes_, \
  292. load_glyph_, get_kerning_, attach_file_, \
  293. get_advances_, request_size_, select_size_ ) \
  294. \
  295. void \
  296. FT_Destroy_Class_##class_( FT_Library library, \
  297. FT_Module_Class* clazz ) \
  298. { \
  299. FT_Memory memory = library->memory; \
  300. FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
  301. class_##_pic_free( library ); \
  302. if ( dclazz ) \
  303. FT_FREE( dclazz ); \
  304. } \
  305. \
  306. FT_Error \
  307. FT_Create_Class_##class_( FT_Library library, \
  308. FT_Module_Class** output_class ) \
  309. { \
  310. FT_Driver_Class clazz; \
  311. FT_Error error; \
  312. FT_Memory memory = library->memory; \
  313. \
  314. if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
  315. return error; \
  316. \
  317. error = class_##_pic_init( library ); \
  318. if(error) \
  319. { \
  320. FT_FREE( clazz ); \
  321. return error; \
  322. } \
  323. \
  324. FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
  325. init_,done_,get_interface_) \
  326. \
  327. clazz->face_object_size = face_object_size_; \
  328. clazz->size_object_size = size_object_size_; \
  329. clazz->slot_object_size = slot_object_size_; \
  330. \
  331. clazz->init_face = init_face_; \
  332. clazz->done_face = done_face_; \
  333. \
  334. clazz->init_size = init_size_; \
  335. clazz->done_size = done_size_; \
  336. \
  337. clazz->init_slot = init_slot_; \
  338. clazz->done_slot = done_slot_; \
  339. \
  340. FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
  341. \
  342. clazz->load_glyph = load_glyph_; \
  343. \
  344. clazz->get_kerning = get_kerning_; \
  345. clazz->attach_file = attach_file_; \
  346. clazz->get_advances = get_advances_; \
  347. \
  348. clazz->request_size = request_size_; \
  349. clazz->select_size = select_size_; \
  350. \
  351. *output_class = (FT_Module_Class*)clazz; \
  352. return FT_Err_Ok; \
  353. }
  354. #endif /* FT_CONFIG_OPTION_PIC */
  355. FT_END_HEADER
  356. #endif /* __FTDRIVER_H__ */
  357. /* END */