ftmodapi.h 34 KB

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