ftmodule.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /***************************************************************************/
  2. /* */
  3. /* ftmodule.h */
  4. /* */
  5. /* FreeType modules public interface (specification). */
  6. /* */
  7. /* Copyright 1996-2001 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 __FTMODULE_H__
  18. #define __FTMODULE_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. FT_BEGIN_HEADER
  22. /*************************************************************************/
  23. /* */
  24. /* <Section> */
  25. /* module_management */
  26. /* */
  27. /* <Title> */
  28. /* Module Management */
  29. /* */
  30. /* <Abstract> */
  31. /* How to add, upgrade, and remove modules from FreeType. */
  32. /* */
  33. /* <Description> */
  34. /* The definitions below are used to manage modules within FreeType. */
  35. /* Modules can be added, upgraded, and removed at runtime. */
  36. /* */
  37. /*************************************************************************/
  38. /* module bit flags */
  39. typedef enum FT_Module_Flags_
  40. {
  41. ft_module_font_driver = 1, /* this module is a font driver */
  42. ft_module_renderer = 2, /* this module is a renderer */
  43. ft_module_hinter = 4, /* this module is a glyph hinter */
  44. ft_module_styler = 8, /* this module is a styler */
  45. ft_module_driver_scalable = 0x100, /* the driver supports scalable */
  46. /* fonts */
  47. ft_module_driver_no_outlines = 0x200, /* the driver does not support */
  48. /* vector outlines */
  49. ft_module_driver_has_hinter = 0x400 /* the driver provides its own */
  50. /* hinter */
  51. } FT_Module_Flags;
  52. typedef void
  53. (*FT_Module_Interface)( void );
  54. typedef FT_Error
  55. (*FT_Module_Constructor)( FT_Module module );
  56. typedef void
  57. (*FT_Module_Destructor)( FT_Module module );
  58. typedef FT_Module_Interface
  59. (*FT_Module_Requester)( FT_Module module,
  60. const char* name );
  61. /*************************************************************************/
  62. /* */
  63. /* <Struct> */
  64. /* FT_Module_Class */
  65. /* */
  66. /* <Description> */
  67. /* The module class descriptor. */
  68. /* */
  69. /* <Fields> */
  70. /* module_flags :: Bit flags describing the module. */
  71. /* */
  72. /* module_size :: The size of one module object/instance in */
  73. /* bytes. */
  74. /* */
  75. /* module_name :: The name of the module. */
  76. /* */
  77. /* module_version :: The version, as a 16.16 fixed number */
  78. /* (major.minor). */
  79. /* */
  80. /* module_requires :: The version of FreeType this module requires */
  81. /* (starts at version 2.0, i.e 0x20000) */
  82. /* */
  83. /* module_init :: A function used to initialize (not create) a */
  84. /* new module object. */
  85. /* */
  86. /* module_done :: A function used to finalize (not destroy) a */
  87. /* given module object */
  88. /* */
  89. /* get_interface :: Queries a given module for a specific */
  90. /* interface by name. */
  91. /* */
  92. typedef struct FT_Module_Class_
  93. {
  94. FT_ULong module_flags;
  95. FT_Long module_size;
  96. const FT_String* module_name;
  97. FT_Fixed module_version;
  98. FT_Fixed module_requires;
  99. const void* module_interface;
  100. FT_Module_Constructor module_init;
  101. FT_Module_Destructor module_done;
  102. FT_Module_Requester get_interface;
  103. } FT_Module_Class;
  104. /*************************************************************************/
  105. /* */
  106. /* <Function> */
  107. /* FT_Add_Module */
  108. /* */
  109. /* <Description> */
  110. /* Adds a new module to a given library instance. */
  111. /* */
  112. /* <InOut> */
  113. /* library :: A handle to the library object. */
  114. /* */
  115. /* <Input> */
  116. /* clazz :: A pointer to class descriptor for the module. */
  117. /* */
  118. /* <Return> */
  119. /* FreeType error code. 0 means success. */
  120. /* */
  121. /* <Note> */
  122. /* An error will be returned if a module already exists by that name, */
  123. /* or if the module requires a version of FreeType that is too great. */
  124. /* */
  125. FT_EXPORT( FT_Error )
  126. FT_Add_Module( FT_Library library,
  127. const FT_Module_Class* clazz );
  128. /*************************************************************************/
  129. /* */
  130. /* <Function> */
  131. /* FT_Get_Module */
  132. /* */
  133. /* <Description> */
  134. /* Finds a module by its name. */
  135. /* */
  136. /* <Input> */
  137. /* library :: A handle to the library object. */
  138. /* */
  139. /* module_name :: The module's name (as an ASCII string). */
  140. /* */
  141. /* <Return> */
  142. /* A module handle. 0 if none was found. */
  143. /* */
  144. /* <Note> */
  145. /* You should better be familiar with FreeType internals to know */
  146. /* which module to look for :-) */
  147. /* */
  148. FT_EXPORT( FT_Module )
  149. FT_Get_Module( FT_Library library,
  150. const char* module_name );
  151. /*************************************************************************/
  152. /* */
  153. /* <Function> */
  154. /* FT_Remove_Module */
  155. /* */
  156. /* <Description> */
  157. /* Removes a given module from a library instance. */
  158. /* */
  159. /* <InOut> */
  160. /* library :: A handle to a library object. */
  161. /* */
  162. /* <Input> */
  163. /* module :: A handle to a module object. */
  164. /* */
  165. /* <Return> */
  166. /* FreeType error code. 0 means success. */
  167. /* */
  168. /* <Note> */
  169. /* The module object is destroyed by the function in case of success. */
  170. /* */
  171. FT_EXPORT( FT_Error )
  172. FT_Remove_Module( FT_Library library,
  173. FT_Module module );
  174. /*************************************************************************/
  175. /* */
  176. /* <Function> */
  177. /* FT_New_Library */
  178. /* */
  179. /* <Description> */
  180. /* This function is used to create a new FreeType library instance */
  181. /* from a given memory object. It is thus possible to use libraries */
  182. /* with distinct memory allocators within the same program. */
  183. /* */
  184. /* <Input> */
  185. /* memory :: A handle to the original memory object. */
  186. /* */
  187. /* <Output> */
  188. /* alibrary :: A pointer to handle of a new library object. */
  189. /* */
  190. /* <Return> */
  191. /* FreeType error code. 0 means success. */
  192. /* */
  193. FT_EXPORT( FT_Error )
  194. FT_New_Library( FT_Memory memory,
  195. FT_Library *alibrary );
  196. /*************************************************************************/
  197. /* */
  198. /* <Function> */
  199. /* FT_Done_Library */
  200. /* */
  201. /* <Description> */
  202. /* Discards a given library object. This closes all drivers and */
  203. /* discards all resource objects. */
  204. /* */
  205. /* <Input> */
  206. /* library :: A handle to the target library. */
  207. /* */
  208. /* <Return> */
  209. /* FreeType error code. 0 means success. */
  210. /* */
  211. FT_EXPORT( FT_Error )
  212. FT_Done_Library( FT_Library library );
  213. typedef void
  214. (*FT_DebugHook_Func)( void* arg );
  215. /*************************************************************************/
  216. /* */
  217. /* <Function> */
  218. /* FT_Set_Debug_Hook */
  219. /* */
  220. /* <Description> */
  221. /* Sets a debug hook function for debugging the interpreter of a font */
  222. /* format. */
  223. /* */
  224. /* <InOut> */
  225. /* library :: A handle to the library object. */
  226. /* */
  227. /* <Input> */
  228. /* hook_index :: The index of the debug hook. You should use the */
  229. /* values defined in ftobjs.h, e.g. */
  230. /* FT_DEBUG_HOOK_TRUETYPE. */
  231. /* */
  232. /* debug_hook :: The function used to debug the interpreter. */
  233. /* */
  234. /* <Note> */
  235. /* Currently, four debug hook slots are available, but only two (for */
  236. /* the TrueType and the Type 1 interpreter) are defined. */
  237. /* */
  238. FT_EXPORT( void )
  239. FT_Set_Debug_Hook( FT_Library library,
  240. FT_UInt hook_index,
  241. FT_DebugHook_Func debug_hook );
  242. /*************************************************************************/
  243. /* */
  244. /* <Function> */
  245. /* FT_Add_Default_Modules */
  246. /* */
  247. /* <Description> */
  248. /* Adds the set of default drivers to a given library object. */
  249. /* This is only useful when you create a library object with */
  250. /* FT_New_Library() (usually to plug a custom memory manager). */
  251. /* */
  252. /* <InOut> */
  253. /* library :: A handle to a new library object. */
  254. /* */
  255. FT_EXPORT( void )
  256. FT_Add_Default_Modules( FT_Library library );
  257. /* */
  258. FT_END_HEADER
  259. #endif /* __FTMODULE_H__ */
  260. /* END */