ftmodapi.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /***************************************************************************/
  2. /* */
  3. /* ftmodapi.h */
  4. /* */
  5. /* FreeType modules public interface (specification). */
  6. /* */
  7. /* Copyright 1996-2003, 2006, 2008-2010, 2012, 2013 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 __FTMODAPI_H__
  18. #define __FTMODAPI_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. #ifdef FREETYPE_H
  22. #error "freetype.h of FreeType 1 has been loaded!"
  23. #error "Please fix the directory search order for header files"
  24. #error "so that freetype.h of FreeType 2 is found first."
  25. #endif
  26. FT_BEGIN_HEADER
  27. /*************************************************************************/
  28. /* */
  29. /* <Section> */
  30. /* module_management */
  31. /* */
  32. /* <Title> */
  33. /* Module Management */
  34. /* */
  35. /* <Abstract> */
  36. /* How to add, upgrade, remove, and control modules from FreeType. */
  37. /* */
  38. /* <Description> */
  39. /* The definitions below are used to manage modules within FreeType. */
  40. /* Modules can be added, upgraded, and removed at runtime. */
  41. /* Additionally, some module properties can be controlled also. */
  42. /* */
  43. /* Here is a list of possible values of the `module_name' field in */
  44. /* the @FT_Module_Class structure. */
  45. /* */
  46. /* { */
  47. /* autofitter */
  48. /* bdf */
  49. /* cff */
  50. /* gxvalid */
  51. /* otvalid */
  52. /* pcf */
  53. /* pfr */
  54. /* psaux */
  55. /* pshinter */
  56. /* psnames */
  57. /* raster1, raster5 */
  58. /* sfnt */
  59. /* smooth, smooth-lcd, smooth-lcdv */
  60. /* truetype */
  61. /* type1 */
  62. /* type42 */
  63. /* t1cid */
  64. /* winfonts */
  65. /* } */
  66. /* */
  67. /* Note that the FreeType Cache sub-system is not a FreeType module. */
  68. /* */
  69. /*************************************************************************/
  70. /* module bit flags */
  71. #define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
  72. #define FT_MODULE_RENDERER 2 /* this module is a renderer */
  73. #define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
  74. #define FT_MODULE_STYLER 8 /* this module is a styler */
  75. #define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
  76. /* scalable fonts */
  77. #define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
  78. /* support vector outlines */
  79. #define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
  80. /* own hinter */
  81. /* deprecated values */
  82. #define ft_module_font_driver FT_MODULE_FONT_DRIVER
  83. #define ft_module_renderer FT_MODULE_RENDERER
  84. #define ft_module_hinter FT_MODULE_HINTER
  85. #define ft_module_styler FT_MODULE_STYLER
  86. #define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
  87. #define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
  88. #define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
  89. typedef FT_Pointer FT_Module_Interface;
  90. /*************************************************************************/
  91. /* */
  92. /* <FuncType> */
  93. /* FT_Module_Constructor */
  94. /* */
  95. /* <Description> */
  96. /* A function used to initialize (not create) a new module object. */
  97. /* */
  98. /* <Input> */
  99. /* module :: The module to initialize. */
  100. /* */
  101. typedef FT_Error
  102. (*FT_Module_Constructor)( FT_Module module );
  103. /*************************************************************************/
  104. /* */
  105. /* <FuncType> */
  106. /* FT_Module_Destructor */
  107. /* */
  108. /* <Description> */
  109. /* A function used to finalize (not destroy) a given module object. */
  110. /* */
  111. /* <Input> */
  112. /* module :: The module to finalize. */
  113. /* */
  114. typedef void
  115. (*FT_Module_Destructor)( FT_Module module );
  116. /*************************************************************************/
  117. /* */
  118. /* <FuncType> */
  119. /* FT_Module_Requester */
  120. /* */
  121. /* <Description> */
  122. /* A function used to query a given module for a specific interface. */
  123. /* */
  124. /* <Input> */
  125. /* module :: The module to be searched. */
  126. /* */
  127. /* name :: The name of the interface in the module. */
  128. /* */
  129. typedef FT_Module_Interface
  130. (*FT_Module_Requester)( FT_Module module,
  131. const char* name );
  132. /*************************************************************************/
  133. /* */
  134. /* <Struct> */
  135. /* FT_Module_Class */
  136. /* */
  137. /* <Description> */
  138. /* The module class descriptor. */
  139. /* */
  140. /* <Fields> */
  141. /* module_flags :: Bit flags describing the module. */
  142. /* */
  143. /* module_size :: The size of one module object/instance in */
  144. /* bytes. */
  145. /* */
  146. /* module_name :: The name of the module. */
  147. /* */
  148. /* module_version :: The version, as a 16.16 fixed number */
  149. /* (major.minor). */
  150. /* */
  151. /* module_requires :: The version of FreeType this module requires, */
  152. /* as a 16.16 fixed number (major.minor). Starts */
  153. /* at version 2.0, i.e., 0x20000. */
  154. /* */
  155. /* module_init :: The initializing function. */
  156. /* */
  157. /* module_done :: The finalizing function. */
  158. /* */
  159. /* get_interface :: The interface requesting function. */
  160. /* */
  161. typedef struct FT_Module_Class_
  162. {
  163. FT_ULong module_flags;
  164. FT_Long module_size;
  165. const FT_String* module_name;
  166. FT_Fixed module_version;
  167. FT_Fixed module_requires;
  168. const void* module_interface;
  169. FT_Module_Constructor module_init;
  170. FT_Module_Destructor module_done;
  171. FT_Module_Requester get_interface;
  172. } FT_Module_Class;
  173. /*************************************************************************/
  174. /* */
  175. /* <Function> */
  176. /* FT_Add_Module */
  177. /* */
  178. /* <Description> */
  179. /* Add a new module to a given library instance. */
  180. /* */
  181. /* <InOut> */
  182. /* library :: A handle to the library object. */
  183. /* */
  184. /* <Input> */
  185. /* clazz :: A pointer to class descriptor for the module. */
  186. /* */
  187. /* <Return> */
  188. /* FreeType error code. 0~means success. */
  189. /* */
  190. /* <Note> */
  191. /* An error will be returned if a module already exists by that name, */
  192. /* or if the module requires a version of FreeType that is too great. */
  193. /* */
  194. FT_EXPORT( FT_Error )
  195. FT_Add_Module( FT_Library library,
  196. const FT_Module_Class* clazz );
  197. /*************************************************************************/
  198. /* */
  199. /* <Function> */
  200. /* FT_Get_Module */
  201. /* */
  202. /* <Description> */
  203. /* Find a module by its name. */
  204. /* */
  205. /* <Input> */
  206. /* library :: A handle to the library object. */
  207. /* */
  208. /* module_name :: The module's name (as an ASCII string). */
  209. /* */
  210. /* <Return> */
  211. /* A module handle. 0~if none was found. */
  212. /* */
  213. /* <Note> */
  214. /* FreeType's internal modules aren't documented very well, and you */
  215. /* should look up the source code for details. */
  216. /* */
  217. FT_EXPORT( FT_Module )
  218. FT_Get_Module( FT_Library library,
  219. const char* module_name );
  220. /*************************************************************************/
  221. /* */
  222. /* <Function> */
  223. /* FT_Remove_Module */
  224. /* */
  225. /* <Description> */
  226. /* Remove a given module from a library instance. */
  227. /* */
  228. /* <InOut> */
  229. /* library :: A handle to a library object. */
  230. /* */
  231. /* <Input> */
  232. /* module :: A handle to a module object. */
  233. /* */
  234. /* <Return> */
  235. /* FreeType error code. 0~means success. */
  236. /* */
  237. /* <Note> */
  238. /* The module object is destroyed by the function in case of success. */
  239. /* */
  240. FT_EXPORT( FT_Error )
  241. FT_Remove_Module( FT_Library library,
  242. FT_Module module );
  243. /**********************************************************************
  244. *
  245. * @function:
  246. * FT_Property_Set
  247. *
  248. * @description:
  249. * Set a property for a given module.
  250. *
  251. * @input:
  252. * library ::
  253. * A handle to the library the module is part of.
  254. *
  255. * module_name ::
  256. * The module name.
  257. *
  258. * property_name ::
  259. * The property name. Properties are described in the `Synopsis'
  260. * subsection of the module's documentation.
  261. *
  262. * Note that only a few modules have properties.
  263. *
  264. * value ::
  265. * A generic pointer to a variable or structure that gives the new
  266. * value of the property. The exact definition of `value' is
  267. * dependent on the property; see the `Synopsis' subsection of the
  268. * module's documentation.
  269. *
  270. * @return:
  271. * FreeType error code. 0~means success.
  272. *
  273. * @note:
  274. * If `module_name' isn't a valid module name, or `property_name'
  275. * doesn't specify a valid property, or if `value' doesn't represent a
  276. * valid value for the given property, an error is returned.
  277. *
  278. * The following example sets property `bar' (a simple integer) in
  279. * module `foo' to value~1.
  280. *
  281. * {
  282. * FT_UInt bar;
  283. *
  284. *
  285. * bar = 1;
  286. * FT_Property_Set( library, "foo", "bar", &bar );
  287. * }
  288. *
  289. * Note that the FreeType Cache sub-system doesn't recognize module
  290. * property changes. To avoid glyph lookup confusion within the cache
  291. * you should call @FTC_Manager_Reset to completely flush the cache if
  292. * a module property gets changed after @FTC_Manager_New has been
  293. * called.
  294. *
  295. * It is not possible to set properties of the FreeType Cache
  296. * sub-system itself with FT_Property_Set; use @FTC_Property_Set
  297. * instead.
  298. *
  299. * @since:
  300. * 2.4.11
  301. *
  302. */
  303. FT_EXPORT( FT_Error )
  304. FT_Property_Set( FT_Library library,
  305. const FT_String* module_name,
  306. const FT_String* property_name,
  307. const void* value );
  308. /**********************************************************************
  309. *
  310. * @function:
  311. * FT_Property_Get
  312. *
  313. * @description:
  314. * Get a module's property value.
  315. *
  316. * @input:
  317. * library ::
  318. * A handle to the library the module is part of.
  319. *
  320. * module_name ::
  321. * The module name.
  322. *
  323. * property_name ::
  324. * The property name. Properties are described in the `Synopsis'
  325. * subsection of the module's documentation.
  326. *
  327. * @inout:
  328. * value ::
  329. * A generic pointer to a variable or structure that gives the
  330. * value of the property. The exact definition of `value' is
  331. * dependent on the property; see the `Synopsis' subsection of the
  332. * module's documentation.
  333. *
  334. * @return:
  335. * FreeType error code. 0~means success.
  336. *
  337. * @note:
  338. * If `module_name' isn't a valid module name, or `property_name'
  339. * doesn't specify a valid property, or if `value' doesn't represent a
  340. * valid value for the given property, an error is returned.
  341. *
  342. * The following example gets property `baz' (a range) in module `foo'.
  343. *
  344. * {
  345. * typedef range_
  346. * {
  347. * FT_Int32 min;
  348. * FT_Int32 max;
  349. *
  350. * } range;
  351. *
  352. * range baz;
  353. *
  354. *
  355. * FT_Property_Get( library, "foo", "baz", &baz );
  356. * }
  357. *
  358. * It is not possible to retrieve properties of the FreeType Cache
  359. * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
  360. *
  361. * @since:
  362. * 2.4.11
  363. *
  364. */
  365. FT_EXPORT( FT_Error )
  366. FT_Property_Get( FT_Library library,
  367. const FT_String* module_name,
  368. const FT_String* property_name,
  369. void* value );
  370. /*************************************************************************/
  371. /* */
  372. /* <Function> */
  373. /* FT_Reference_Library */
  374. /* */
  375. /* <Description> */
  376. /* A counter gets initialized to~1 at the time an @FT_Library */
  377. /* structure is created. This function increments the counter. */
  378. /* @FT_Done_Library then only destroys a library if the counter is~1, */
  379. /* otherwise it simply decrements the counter. */
  380. /* */
  381. /* This function helps in managing life-cycles of structures that */
  382. /* reference @FT_Library objects. */
  383. /* */
  384. /* <Input> */
  385. /* library :: A handle to a target library object. */
  386. /* */
  387. /* <Return> */
  388. /* FreeType error code. 0~means success. */
  389. /* */
  390. /* <Since> */
  391. /* 2.4.2 */
  392. /* */
  393. FT_EXPORT( FT_Error )
  394. FT_Reference_Library( FT_Library library );
  395. /*************************************************************************/
  396. /* */
  397. /* <Function> */
  398. /* FT_New_Library */
  399. /* */
  400. /* <Description> */
  401. /* This function is used to create a new FreeType library instance */
  402. /* from a given memory object. It is thus possible to use libraries */
  403. /* with distinct memory allocators within the same program. */
  404. /* */
  405. /* Normally, you would call this function (followed by a call to */
  406. /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
  407. /* instead of @FT_Init_FreeType to initialize the FreeType library. */
  408. /* */
  409. /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
  410. /* library instance. */
  411. /* */
  412. /* <Input> */
  413. /* memory :: A handle to the original memory object. */
  414. /* */
  415. /* <Output> */
  416. /* alibrary :: A pointer to handle of a new library object. */
  417. /* */
  418. /* <Return> */
  419. /* FreeType error code. 0~means success. */
  420. /* */
  421. /* <Note> */
  422. /* See the discussion of reference counters in the description of */
  423. /* @FT_Reference_Library. */
  424. /* */
  425. FT_EXPORT( FT_Error )
  426. FT_New_Library( FT_Memory memory,
  427. FT_Library *alibrary );
  428. /*************************************************************************/
  429. /* */
  430. /* <Function> */
  431. /* FT_Done_Library */
  432. /* */
  433. /* <Description> */
  434. /* Discard a given library object. This closes all drivers and */
  435. /* discards all resource objects. */
  436. /* */
  437. /* <Input> */
  438. /* library :: A handle to the target library. */
  439. /* */
  440. /* <Return> */
  441. /* FreeType error code. 0~means success. */
  442. /* */
  443. /* <Note> */
  444. /* See the discussion of reference counters in the description of */
  445. /* @FT_Reference_Library. */
  446. /* */
  447. FT_EXPORT( FT_Error )
  448. FT_Done_Library( FT_Library library );
  449. /* */
  450. typedef void
  451. (*FT_DebugHook_Func)( void* arg );
  452. /*************************************************************************/
  453. /* */
  454. /* <Function> */
  455. /* FT_Set_Debug_Hook */
  456. /* */
  457. /* <Description> */
  458. /* Set a debug hook function for debugging the interpreter of a font */
  459. /* format. */
  460. /* */
  461. /* <InOut> */
  462. /* library :: A handle to the library object. */
  463. /* */
  464. /* <Input> */
  465. /* hook_index :: The index of the debug hook. You should use the */
  466. /* values defined in `ftobjs.h', e.g., */
  467. /* `FT_DEBUG_HOOK_TRUETYPE'. */
  468. /* */
  469. /* debug_hook :: The function used to debug the interpreter. */
  470. /* */
  471. /* <Note> */
  472. /* Currently, four debug hook slots are available, but only two (for */
  473. /* the TrueType and the Type~1 interpreter) are defined. */
  474. /* */
  475. /* Since the internal headers of FreeType are no longer installed, */
  476. /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
  477. /* This is a bug and will be fixed in a forthcoming release. */
  478. /* */
  479. FT_EXPORT( void )
  480. FT_Set_Debug_Hook( FT_Library library,
  481. FT_UInt hook_index,
  482. FT_DebugHook_Func debug_hook );
  483. /*************************************************************************/
  484. /* */
  485. /* <Function> */
  486. /* FT_Add_Default_Modules */
  487. /* */
  488. /* <Description> */
  489. /* Add the set of default drivers to a given library object. */
  490. /* This is only useful when you create a library object with */
  491. /* @FT_New_Library (usually to plug a custom memory manager). */
  492. /* */
  493. /* <InOut> */
  494. /* library :: A handle to a new library object. */
  495. /* */
  496. FT_EXPORT( void )
  497. FT_Add_Default_Modules( FT_Library library );
  498. /**************************************************************************
  499. *
  500. * @section:
  501. * truetype_engine
  502. *
  503. * @title:
  504. * The TrueType Engine
  505. *
  506. * @abstract:
  507. * TrueType bytecode support.
  508. *
  509. * @description:
  510. * This section contains a function used to query the level of TrueType
  511. * bytecode support compiled in this version of the library.
  512. *
  513. */
  514. /**************************************************************************
  515. *
  516. * @enum:
  517. * FT_TrueTypeEngineType
  518. *
  519. * @description:
  520. * A list of values describing which kind of TrueType bytecode
  521. * engine is implemented in a given FT_Library instance. It is used
  522. * by the @FT_Get_TrueType_Engine_Type function.
  523. *
  524. * @values:
  525. * FT_TRUETYPE_ENGINE_TYPE_NONE ::
  526. * The library doesn't implement any kind of bytecode interpreter.
  527. *
  528. * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
  529. * The library implements a bytecode interpreter that doesn't
  530. * support the patented operations of the TrueType virtual machine.
  531. *
  532. * Its main use is to load certain Asian fonts that position and
  533. * scale glyph components with bytecode instructions. It produces
  534. * bad output for most other fonts.
  535. *
  536. * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
  537. * The library implements a bytecode interpreter that covers
  538. * the full instruction set of the TrueType virtual machine (this
  539. * was governed by patents until May 2010, hence the name).
  540. *
  541. * @since:
  542. * 2.2
  543. *
  544. */
  545. typedef enum FT_TrueTypeEngineType_
  546. {
  547. FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
  548. FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
  549. FT_TRUETYPE_ENGINE_TYPE_PATENTED
  550. } FT_TrueTypeEngineType;
  551. /**************************************************************************
  552. *
  553. * @func:
  554. * FT_Get_TrueType_Engine_Type
  555. *
  556. * @description:
  557. * Return an @FT_TrueTypeEngineType value to indicate which level of
  558. * the TrueType virtual machine a given library instance supports.
  559. *
  560. * @input:
  561. * library ::
  562. * A library instance.
  563. *
  564. * @return:
  565. * A value indicating which level is supported.
  566. *
  567. * @since:
  568. * 2.2
  569. *
  570. */
  571. FT_EXPORT( FT_TrueTypeEngineType )
  572. FT_Get_TrueType_Engine_Type( FT_Library library );
  573. /* */
  574. FT_END_HEADER
  575. #endif /* __FTMODAPI_H__ */
  576. /* END */