sfnt.h 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. /***************************************************************************/
  2. /* */
  3. /* sfnt.h */
  4. /* */
  5. /* High-level `sfnt' driver interface (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 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 __SFNT_H__
  18. #define __SFNT_H__
  19. #include <ft2build.h>
  20. #include FT_INTERNAL_DRIVER_H
  21. #include FT_INTERNAL_TRUETYPE_TYPES_H
  22. FT_BEGIN_HEADER
  23. /*************************************************************************/
  24. /* */
  25. /* <FuncType> */
  26. /* TT_Init_Face_Func */
  27. /* */
  28. /* <Description> */
  29. /* First part of the SFNT face object initialization. This finds */
  30. /* the face in a SFNT file or collection, and load its format tag in */
  31. /* face->format_tag. */
  32. /* */
  33. /* <Input> */
  34. /* stream :: The input stream. */
  35. /* */
  36. /* face :: A handle to the target face object. */
  37. /* */
  38. /* face_index :: The index of the TrueType font, if we are opening a */
  39. /* collection. */
  40. /* */
  41. /* num_params :: The number of additional parameters. */
  42. /* */
  43. /* params :: Optional additional parameters. */
  44. /* */
  45. /* <Return> */
  46. /* FreeType error code. 0 means success. */
  47. /* */
  48. /* <Note> */
  49. /* The stream cursor must be at the font file's origin. */
  50. /* */
  51. /* This function recognizes fonts embedded in a `TrueType */
  52. /* collection'. */
  53. /* */
  54. /* Once the format tag has been validated by the font driver, it */
  55. /* should then call the TT_Load_Face_Func() callback to read the rest */
  56. /* of the SFNT tables in the object. */
  57. /* */
  58. typedef FT_Error
  59. (*TT_Init_Face_Func)( FT_Stream stream,
  60. TT_Face face,
  61. FT_Int face_index,
  62. FT_Int num_params,
  63. FT_Parameter* params );
  64. /*************************************************************************/
  65. /* */
  66. /* <FuncType> */
  67. /* TT_Load_Face_Func */
  68. /* */
  69. /* <Description> */
  70. /* Second part of the SFNT face object initialization. This loads */
  71. /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */
  72. /* face object. */
  73. /* */
  74. /* <Input> */
  75. /* stream :: The input stream. */
  76. /* */
  77. /* face :: A handle to the target face object. */
  78. /* */
  79. /* face_index :: The index of the TrueType font, if we are opening a */
  80. /* collection. */
  81. /* */
  82. /* num_params :: The number of additional parameters. */
  83. /* */
  84. /* params :: Optional additional parameters. */
  85. /* */
  86. /* <Return> */
  87. /* FreeType error code. 0 means success. */
  88. /* */
  89. /* <Note> */
  90. /* This function must be called after TT_Init_Face_Func(). */
  91. /* */
  92. typedef FT_Error
  93. (*TT_Load_Face_Func)( FT_Stream stream,
  94. TT_Face face,
  95. FT_Int face_index,
  96. FT_Int num_params,
  97. FT_Parameter* params );
  98. /*************************************************************************/
  99. /* */
  100. /* <FuncType> */
  101. /* TT_Done_Face_Func */
  102. /* */
  103. /* <Description> */
  104. /* A callback used to delete the common SFNT data from a face. */
  105. /* */
  106. /* <Input> */
  107. /* face :: A handle to the target face object. */
  108. /* */
  109. /* <Note> */
  110. /* This function does NOT destroy the face object. */
  111. /* */
  112. typedef void
  113. (*TT_Done_Face_Func)( TT_Face face );
  114. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  115. /*************************************************************************/
  116. /* */
  117. /* <FuncType> */
  118. /* TT_Load_SFNT_HeaderRec_Func */
  119. /* */
  120. /* <Description> */
  121. /* Loads the header of a SFNT font file. Supports collections. */
  122. /* */
  123. /* <Input> */
  124. /* face :: A handle to the target face object. */
  125. /* */
  126. /* stream :: The input stream. */
  127. /* */
  128. /* face_index :: The index of the TrueType font, if we are opening a */
  129. /* collection. */
  130. /* */
  131. /* <Output> */
  132. /* sfnt :: The SFNT header. */
  133. /* */
  134. /* <Return> */
  135. /* FreeType error code. 0 means success. */
  136. /* */
  137. /* <Note> */
  138. /* The stream cursor must be at the font file's origin. */
  139. /* */
  140. /* This function recognizes fonts embedded in a `TrueType */
  141. /* collection'. */
  142. /* */
  143. /* This function checks that the header is valid by looking at the */
  144. /* values of `search_range', `entry_selector', and `range_shift'. */
  145. /* */
  146. typedef FT_Error
  147. (*TT_Load_SFNT_HeaderRec_Func)( TT_Face face,
  148. FT_Stream stream,
  149. FT_Long face_index,
  150. SFNT_Header sfnt );
  151. /*************************************************************************/
  152. /* */
  153. /* <FuncType> */
  154. /* TT_Load_Directory_Func */
  155. /* */
  156. /* <Description> */
  157. /* Loads the table directory into a face object. */
  158. /* */
  159. /* <Input> */
  160. /* face :: A handle to the target face object. */
  161. /* */
  162. /* stream :: The input stream. */
  163. /* */
  164. /* sfnt :: The SFNT header. */
  165. /* */
  166. /* <Return> */
  167. /* FreeType error code. 0 means success. */
  168. /* */
  169. /* <Note> */
  170. /* The stream cursor must be on the first byte after the 4-byte font */
  171. /* format tag. This is the case just after a call to */
  172. /* TT_Load_Format_Tag(). */
  173. /* */
  174. typedef FT_Error
  175. (*TT_Load_Directory_Func)( TT_Face face,
  176. FT_Stream stream,
  177. SFNT_Header sfnt );
  178. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  179. /*************************************************************************/
  180. /* */
  181. /* <FuncType> */
  182. /* TT_Load_Any_Func */
  183. /* */
  184. /* <Description> */
  185. /* Load any font table into client memory. */
  186. /* */
  187. /* <Input> */
  188. /* face :: The face object to look for. */
  189. /* */
  190. /* tag :: The tag of table to load. Use the value 0 if you want */
  191. /* to access the whole font file, else set this parameter */
  192. /* to a valid TrueType table tag that you can forge with */
  193. /* the MAKE_TT_TAG macro. */
  194. /* */
  195. /* offset :: The starting offset in the table (or the file if */
  196. /* tag == 0). */
  197. /* */
  198. /* length :: The address of the decision variable: */
  199. /* */
  200. /* If length == NULL: */
  201. /* Loads the whole table. Returns an error if */
  202. /* `offset' == 0! */
  203. /* */
  204. /* If *length == 0: */
  205. /* Exits immediately; returning the length of the given */
  206. /* table or of the font file, depending on the value of */
  207. /* `tag'. */
  208. /* */
  209. /* If *length != 0: */
  210. /* Loads the next `length' bytes of table or font, */
  211. /* starting at offset `offset' (in table or font too). */
  212. /* */
  213. /* <Output> */
  214. /* buffer :: The address of target buffer. */
  215. /* */
  216. /* <Return> */
  217. /* TrueType error code. 0 means success. */
  218. /* */
  219. typedef FT_Error
  220. (*TT_Load_Any_Func)( TT_Face face,
  221. FT_ULong tag,
  222. FT_Long offset,
  223. FT_Byte *buffer,
  224. FT_ULong* length );
  225. /*************************************************************************/
  226. /* */
  227. /* <FuncType> */
  228. /* TT_Find_SBit_Image_Func */
  229. /* */
  230. /* <Description> */
  231. /* Check whether an embedded bitmap (an `sbit') exists for a given */
  232. /* glyph, at a given strike. */
  233. /* */
  234. /* <Input> */
  235. /* face :: The target face object. */
  236. /* */
  237. /* glyph_index :: The glyph index. */
  238. /* */
  239. /* strike_index :: The current strike index. */
  240. /* */
  241. /* <Output> */
  242. /* arange :: The SBit range containing the glyph index. */
  243. /* */
  244. /* astrike :: The SBit strike containing the glyph index. */
  245. /* */
  246. /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
  247. /* */
  248. /* <Return> */
  249. /* FreeType error code. 0 means success. Returns */
  250. /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */
  251. /* glyph. */
  252. /* */
  253. typedef FT_Error
  254. (*TT_Find_SBit_Image_Func)( TT_Face face,
  255. FT_UInt glyph_index,
  256. FT_ULong strike_index,
  257. TT_SBit_Range *arange,
  258. TT_SBit_Strike *astrike,
  259. FT_ULong *aglyph_offset );
  260. /*************************************************************************/
  261. /* */
  262. /* <FuncType> */
  263. /* TT_Load_SBit_Metrics_Func */
  264. /* */
  265. /* <Description> */
  266. /* Get the big metrics for a given embedded bitmap. */
  267. /* */
  268. /* <Input> */
  269. /* stream :: The input stream. */
  270. /* */
  271. /* range :: The SBit range containing the glyph. */
  272. /* */
  273. /* <Output> */
  274. /* big_metrics :: A big SBit metrics structure for the glyph. */
  275. /* */
  276. /* <Return> */
  277. /* FreeType error code. 0 means success. */
  278. /* */
  279. /* <Note> */
  280. /* The stream cursor must be positioned at the glyph's offset within */
  281. /* the `EBDT' table before the call. */
  282. /* */
  283. /* If the image format uses variable metrics, the stream cursor is */
  284. /* positioned just after the metrics header in the `EBDT' table on */
  285. /* function exit. */
  286. /* */
  287. typedef FT_Error
  288. (*TT_Load_SBit_Metrics_Func)( FT_Stream stream,
  289. TT_SBit_Range range,
  290. TT_SBit_Metrics metrics );
  291. /*************************************************************************/
  292. /* */
  293. /* <FuncType> */
  294. /* TT_Load_SBit_Image_Func */
  295. /* */
  296. /* <Description> */
  297. /* Load a given glyph sbit image from the font resource. This also */
  298. /* returns its metrics. */
  299. /* */
  300. /* <Input> */
  301. /* face :: */
  302. /* The target face object. */
  303. /* */
  304. /* strike_index :: */
  305. /* The strike index. */
  306. /* */
  307. /* glyph_index :: */
  308. /* The current glyph index. */
  309. /* */
  310. /* load_flags :: */
  311. /* The current load flags. */
  312. /* */
  313. /* stream :: */
  314. /* The input stream. */
  315. /* */
  316. /* <Output> */
  317. /* amap :: */
  318. /* The target pixmap. */
  319. /* */
  320. /* ametrics :: */
  321. /* A big sbit metrics structure for the glyph image. */
  322. /* */
  323. /* <Return> */
  324. /* FreeType error code. 0 means success. Returns an error if no */
  325. /* glyph sbit exists for the index. */
  326. /* */
  327. /* <Note> */
  328. /* The `map.buffer' field is always freed before the glyph is loaded. */
  329. /* */
  330. typedef FT_Error
  331. (*TT_Load_SBit_Image_Func)( TT_Face face,
  332. FT_ULong strike_index,
  333. FT_UInt glyph_index,
  334. FT_UInt load_flags,
  335. FT_Stream stream,
  336. FT_Bitmap *amap,
  337. TT_SBit_MetricsRec *ametrics );
  338. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  339. /*************************************************************************/
  340. /* */
  341. /* <FuncType> */
  342. /* TT_Set_SBit_Strike_OldFunc */
  343. /* */
  344. /* <Description> */
  345. /* Select an sbit strike for a given size request. */
  346. /* */
  347. /* <Input> */
  348. /* face :: The target face object. */
  349. /* */
  350. /* req :: The size request. */
  351. /* */
  352. /* <Output> */
  353. /* astrike_index :: The index of the sbit strike. */
  354. /* */
  355. /* <Return> */
  356. /* FreeType error code. 0 means success. Returns an error if no */
  357. /* sbit strike exists for the selected ppem values. */
  358. /* */
  359. typedef FT_Error
  360. (*TT_Set_SBit_Strike_OldFunc)( TT_Face face,
  361. FT_UInt x_ppem,
  362. FT_UInt y_ppem,
  363. FT_ULong* astrike_index );
  364. /*************************************************************************/
  365. /* */
  366. /* <FuncType> */
  367. /* TT_CharMap_Load_Func */
  368. /* */
  369. /* <Description> */
  370. /* Loads a given TrueType character map into memory. */
  371. /* */
  372. /* <Input> */
  373. /* face :: A handle to the parent face object. */
  374. /* */
  375. /* stream :: A handle to the current stream object. */
  376. /* */
  377. /* <InOut> */
  378. /* cmap :: A pointer to a cmap object. */
  379. /* */
  380. /* <Return> */
  381. /* FreeType error code. 0 means success. */
  382. /* */
  383. /* <Note> */
  384. /* The function assumes that the stream is already in use (i.e., */
  385. /* opened). In case of error, all partially allocated tables are */
  386. /* released. */
  387. /* */
  388. typedef FT_Error
  389. (*TT_CharMap_Load_Func)( TT_Face face,
  390. void* cmap,
  391. FT_Stream input );
  392. /*************************************************************************/
  393. /* */
  394. /* <FuncType> */
  395. /* TT_CharMap_Free_Func */
  396. /* */
  397. /* <Description> */
  398. /* Destroys a character mapping table. */
  399. /* */
  400. /* <Input> */
  401. /* face :: A handle to the parent face object. */
  402. /* */
  403. /* cmap :: A handle to a cmap object. */
  404. /* */
  405. /* <Return> */
  406. /* FreeType error code. 0 means success. */
  407. /* */
  408. typedef FT_Error
  409. (*TT_CharMap_Free_Func)( TT_Face face,
  410. void* cmap );
  411. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  412. /*************************************************************************/
  413. /* */
  414. /* <FuncType> */
  415. /* TT_Set_SBit_Strike_Func */
  416. /* */
  417. /* <Description> */
  418. /* Select an sbit strike for a given size request. */
  419. /* */
  420. /* <Input> */
  421. /* face :: The target face object. */
  422. /* */
  423. /* req :: The size request. */
  424. /* */
  425. /* <Output> */
  426. /* astrike_index :: The index of the sbit strike. */
  427. /* */
  428. /* <Return> */
  429. /* FreeType error code. 0 means success. Returns an error if no */
  430. /* sbit strike exists for the selected ppem values. */
  431. /* */
  432. typedef FT_Error
  433. (*TT_Set_SBit_Strike_Func)( TT_Face face,
  434. FT_Size_Request req,
  435. FT_ULong* astrike_index );
  436. /*************************************************************************/
  437. /* */
  438. /* <FuncType> */
  439. /* TT_Load_Strike_Metrics_Func */
  440. /* */
  441. /* <Description> */
  442. /* Load the metrics of a given strike. */
  443. /* */
  444. /* <Input> */
  445. /* face :: The target face object. */
  446. /* */
  447. /* strike_index :: The strike index. */
  448. /* */
  449. /* <Output> */
  450. /* metrics :: the metrics of the strike. */
  451. /* */
  452. /* <Return> */
  453. /* FreeType error code. 0 means success. Returns an error if no */
  454. /* such sbit strike exists. */
  455. /* */
  456. typedef FT_Error
  457. (*TT_Load_Strike_Metrics_Func)( TT_Face face,
  458. FT_ULong strike_index,
  459. FT_Size_Metrics* metrics );
  460. /*************************************************************************/
  461. /* */
  462. /* <FuncType> */
  463. /* TT_Get_PS_Name_Func */
  464. /* */
  465. /* <Description> */
  466. /* Get the PostScript glyph name of a glyph. */
  467. /* */
  468. /* <Input> */
  469. /* idx :: The glyph index. */
  470. /* */
  471. /* PSname :: The address of a string pointer. Will be NULL in case */
  472. /* of error, otherwise it is a pointer to the glyph name. */
  473. /* */
  474. /* You must not modify the returned string! */
  475. /* */
  476. /* <Output> */
  477. /* FreeType error code. 0 means success. */
  478. /* */
  479. typedef FT_Error
  480. (*TT_Get_PS_Name_Func)( TT_Face face,
  481. FT_UInt idx,
  482. FT_String** PSname );
  483. /*************************************************************************/
  484. /* */
  485. /* <FuncType> */
  486. /* TT_Load_Metrics_Func */
  487. /* */
  488. /* <Description> */
  489. /* Load a metrics table, which is a table with a horizontal and a */
  490. /* vertical version. */
  491. /* */
  492. /* <Input> */
  493. /* face :: A handle to the target face object. */
  494. /* */
  495. /* stream :: The input stream. */
  496. /* */
  497. /* vertical :: A boolean flag. If set, load the vertical one. */
  498. /* */
  499. /* <Return> */
  500. /* FreeType error code. 0 means success. */
  501. /* */
  502. typedef FT_Error
  503. (*TT_Load_Metrics_Func)( TT_Face face,
  504. FT_Stream stream,
  505. FT_Bool vertical );
  506. /*************************************************************************/
  507. /* */
  508. /* <FuncType> */
  509. /* TT_Get_Metrics_Func */
  510. /* */
  511. /* <Description> */
  512. /* Load the horizontal or vertical header in a face object. */
  513. /* */
  514. /* <Input> */
  515. /* face :: A handle to the target face object. */
  516. /* */
  517. /* stream :: The input stream. */
  518. /* */
  519. /* vertical :: A boolean flag. If set, load vertical metrics. */
  520. /* */
  521. /* <Return> */
  522. /* FreeType error code. 0 means success. */
  523. /* */
  524. typedef FT_Error
  525. (*TT_Get_Metrics_Func)( TT_Face face,
  526. FT_Bool vertical,
  527. FT_UInt gindex,
  528. FT_Short* abearing,
  529. FT_UShort* aadvance );
  530. /*************************************************************************/
  531. /* */
  532. /* <FuncType> */
  533. /* TT_Load_Table_Func */
  534. /* */
  535. /* <Description> */
  536. /* Load a given TrueType table. */
  537. /* */
  538. /* <Input> */
  539. /* face :: A handle to the target face object. */
  540. /* */
  541. /* stream :: The input stream. */
  542. /* */
  543. /* <Return> */
  544. /* FreeType error code. 0 means success. */
  545. /* */
  546. /* <Note> */
  547. /* The function uses `face->goto_table' to seek the stream to the */
  548. /* start of the table, except while loading the font directory. */
  549. /* */
  550. typedef FT_Error
  551. (*TT_Load_Table_Func)( TT_Face face,
  552. FT_Stream stream );
  553. /*************************************************************************/
  554. /* */
  555. /* <FuncType> */
  556. /* TT_Free_Table_Func */
  557. /* */
  558. /* <Description> */
  559. /* Free a given TrueType table. */
  560. /* */
  561. /* <Input> */
  562. /* face :: A handle to the target face object. */
  563. /* */
  564. typedef void
  565. (*TT_Free_Table_Func)( TT_Face face );
  566. /*
  567. * @functype:
  568. * TT_Face_GetKerningFunc
  569. *
  570. * @description:
  571. * Return the horizontal kerning value between two glyphs.
  572. *
  573. * @input:
  574. * face :: A handle to the source face object.
  575. * left_glyph :: The left glyph index.
  576. * right_glyph :: The right glyph index.
  577. *
  578. * @return:
  579. * The kerning value in font units.
  580. */
  581. typedef FT_Int
  582. (*TT_Face_GetKerningFunc)( TT_Face face,
  583. FT_UInt left_glyph,
  584. FT_UInt right_glyph );
  585. /*************************************************************************/
  586. /* */
  587. /* <Struct> */
  588. /* SFNT_Interface */
  589. /* */
  590. /* <Description> */
  591. /* This structure holds pointers to the functions used to load and */
  592. /* free the basic tables that are required in a `sfnt' font file. */
  593. /* */
  594. /* <Fields> */
  595. /* Check the various xxx_Func() descriptions for details. */
  596. /* */
  597. typedef struct SFNT_Interface_
  598. {
  599. TT_Loader_GotoTableFunc goto_table;
  600. TT_Init_Face_Func init_face;
  601. TT_Load_Face_Func load_face;
  602. TT_Done_Face_Func done_face;
  603. FT_Module_Requester get_interface;
  604. TT_Load_Any_Func load_any;
  605. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  606. TT_Load_SFNT_HeaderRec_Func load_sfnt_header;
  607. TT_Load_Directory_Func load_directory;
  608. #endif
  609. /* these functions are called by `load_face' but they can also */
  610. /* be called from external modules, if there is a need to do so */
  611. TT_Load_Table_Func load_head;
  612. TT_Load_Metrics_Func load_hhea;
  613. TT_Load_Table_Func load_cmap;
  614. TT_Load_Table_Func load_maxp;
  615. TT_Load_Table_Func load_os2;
  616. TT_Load_Table_Func load_post;
  617. TT_Load_Table_Func load_name;
  618. TT_Free_Table_Func free_name;
  619. /* optional tables */
  620. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  621. TT_Load_Table_Func load_hdmx_stub;
  622. TT_Free_Table_Func free_hdmx_stub;
  623. #endif
  624. /* this field was called `load_kerning' up to version 2.1.10 */
  625. TT_Load_Table_Func load_kern;
  626. TT_Load_Table_Func load_gasp;
  627. TT_Load_Table_Func load_pclt;
  628. /* see `ttload.h'; this field was called `load_bitmap_header' up to */
  629. /* version 2.1.10 */
  630. TT_Load_Table_Func load_bhed;
  631. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  632. /* see `ttsbit.h' */
  633. TT_Set_SBit_Strike_OldFunc set_sbit_strike_stub;
  634. TT_Load_Table_Func load_sbits_stub;
  635. /*
  636. * The following two fields appeared in version 2.1.8, and were placed
  637. * between `load_sbits' and `load_sbit_image'. We support them as a
  638. * special exception since they are used by Xfont library within the
  639. * X.Org xserver, and because the probability that other rogue clients
  640. * use the other version 2.1.7 fields below is _extremely_ low.
  641. *
  642. * Note that this forces us to disable an interesting memory-saving
  643. * optimization though...
  644. */
  645. TT_Find_SBit_Image_Func find_sbit_image;
  646. TT_Load_SBit_Metrics_Func load_sbit_metrics;
  647. #endif
  648. TT_Load_SBit_Image_Func load_sbit_image;
  649. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  650. TT_Free_Table_Func free_sbits_stub;
  651. #endif
  652. /* see `ttpost.h' */
  653. TT_Get_PS_Name_Func get_psname;
  654. TT_Free_Table_Func free_psnames;
  655. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  656. TT_CharMap_Load_Func load_charmap_stub;
  657. TT_CharMap_Free_Func free_charmap_stub;
  658. #endif
  659. /* starting here, the structure differs from version 2.1.7 */
  660. /* this field was introduced in version 2.1.8, named `get_psname' */
  661. TT_Face_GetKerningFunc get_kerning;
  662. /* new elements introduced after version 2.1.10 */
  663. /* load the font directory, i.e., the offset table and */
  664. /* the table directory */
  665. TT_Load_Table_Func load_font_dir;
  666. TT_Load_Metrics_Func load_hmtx;
  667. TT_Load_Table_Func load_eblc;
  668. TT_Free_Table_Func free_eblc;
  669. TT_Set_SBit_Strike_Func set_sbit_strike;
  670. TT_Load_Strike_Metrics_Func load_strike_metrics;
  671. TT_Get_Metrics_Func get_metrics;
  672. } SFNT_Interface;
  673. /* transitional */
  674. typedef SFNT_Interface* SFNT_Service;
  675. #ifndef FT_CONFIG_OPTION_PIC
  676. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  677. #define FT_DEFINE_DRIVERS_OLD_INTERNAL(a) \
  678. a,
  679. #else
  680. #define FT_DEFINE_DRIVERS_OLD_INTERNAL(a)
  681. #endif
  682. #define FT_INTERNAL(a) \
  683. a,
  684. #define FT_DEFINE_SFNT_INTERFACE(class_, \
  685. goto_table_, init_face_, load_face_, done_face_, get_interface_, \
  686. load_any_, load_sfnt_header_, load_directory_, load_head_, \
  687. load_hhea_, load_cmap_, load_maxp_, load_os2_, load_post_, \
  688. load_name_, free_name_, load_hdmx_stub_, free_hdmx_stub_, \
  689. load_kern_, load_gasp_, load_pclt_, load_bhed_, \
  690. set_sbit_strike_stub_, load_sbits_stub_, find_sbit_image_, \
  691. load_sbit_metrics_, load_sbit_image_, free_sbits_stub_, \
  692. get_psname_, free_psnames_, load_charmap_stub_, free_charmap_stub_, \
  693. get_kerning_, load_font_dir_, load_hmtx_, load_eblc_, free_eblc_, \
  694. set_sbit_strike_, load_strike_metrics_, get_metrics_ ) \
  695. static const SFNT_Interface class_ = \
  696. { \
  697. FT_INTERNAL(goto_table_) \
  698. FT_INTERNAL(init_face_) \
  699. FT_INTERNAL(load_face_) \
  700. FT_INTERNAL(done_face_) \
  701. FT_INTERNAL(get_interface_) \
  702. FT_INTERNAL(load_any_) \
  703. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sfnt_header_) \
  704. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_directory_) \
  705. FT_INTERNAL(load_head_) \
  706. FT_INTERNAL(load_hhea_) \
  707. FT_INTERNAL(load_cmap_) \
  708. FT_INTERNAL(load_maxp_) \
  709. FT_INTERNAL(load_os2_) \
  710. FT_INTERNAL(load_post_) \
  711. FT_INTERNAL(load_name_) \
  712. FT_INTERNAL(free_name_) \
  713. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_hdmx_stub_) \
  714. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_hdmx_stub_) \
  715. FT_INTERNAL(load_kern_) \
  716. FT_INTERNAL(load_gasp_) \
  717. FT_INTERNAL(load_pclt_) \
  718. FT_INTERNAL(load_bhed_) \
  719. FT_DEFINE_DRIVERS_OLD_INTERNAL(set_sbit_strike_stub_) \
  720. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbits_stub_) \
  721. FT_DEFINE_DRIVERS_OLD_INTERNAL(find_sbit_image_) \
  722. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbit_metrics_) \
  723. FT_INTERNAL(load_sbit_image_) \
  724. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_sbits_stub_) \
  725. FT_INTERNAL(get_psname_) \
  726. FT_INTERNAL(free_psnames_) \
  727. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_charmap_stub_) \
  728. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_charmap_stub_) \
  729. FT_INTERNAL(get_kerning_) \
  730. FT_INTERNAL(load_font_dir_) \
  731. FT_INTERNAL(load_hmtx_) \
  732. FT_INTERNAL(load_eblc_) \
  733. FT_INTERNAL(free_eblc_) \
  734. FT_INTERNAL(set_sbit_strike_) \
  735. FT_INTERNAL(load_strike_metrics_) \
  736. FT_INTERNAL(get_metrics_) \
  737. };
  738. #else /* FT_CONFIG_OPTION_PIC */
  739. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  740. #define FT_DEFINE_DRIVERS_OLD_INTERNAL(a, a_) \
  741. clazz->a = a_;
  742. #else
  743. #define FT_DEFINE_DRIVERS_OLD_INTERNAL(a, a_)
  744. #endif
  745. #define FT_INTERNAL(a, a_) \
  746. clazz->a = a_;
  747. #define FT_DEFINE_SFNT_INTERFACE(class_, \
  748. goto_table_, init_face_, load_face_, done_face_, get_interface_, \
  749. load_any_, load_sfnt_header_, load_directory_, load_head_, \
  750. load_hhea_, load_cmap_, load_maxp_, load_os2_, load_post_, \
  751. load_name_, free_name_, load_hdmx_stub_, free_hdmx_stub_, \
  752. load_kern_, load_gasp_, load_pclt_, load_bhed_, \
  753. set_sbit_strike_stub_, load_sbits_stub_, find_sbit_image_, \
  754. load_sbit_metrics_, load_sbit_image_, free_sbits_stub_, \
  755. get_psname_, free_psnames_, load_charmap_stub_, free_charmap_stub_, \
  756. get_kerning_, load_font_dir_, load_hmtx_, load_eblc_, free_eblc_, \
  757. set_sbit_strike_, load_strike_metrics_, get_metrics_ ) \
  758. void \
  759. FT_Init_Class_##class_( FT_Library library, SFNT_Interface* clazz ) \
  760. { \
  761. FT_UNUSED(library); \
  762. FT_INTERNAL(goto_table,goto_table_) \
  763. FT_INTERNAL(init_face,init_face_) \
  764. FT_INTERNAL(load_face,load_face_) \
  765. FT_INTERNAL(done_face,done_face_) \
  766. FT_INTERNAL(get_interface,get_interface_) \
  767. FT_INTERNAL(load_any,load_any_) \
  768. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sfnt_header,load_sfnt_header_) \
  769. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_directory,load_directory_) \
  770. FT_INTERNAL(load_head,load_head_) \
  771. FT_INTERNAL(load_hhea,load_hhea_) \
  772. FT_INTERNAL(load_cmap,load_cmap_) \
  773. FT_INTERNAL(load_maxp,load_maxp_) \
  774. FT_INTERNAL(load_os2,load_os2_) \
  775. FT_INTERNAL(load_post,load_post_) \
  776. FT_INTERNAL(load_name,load_name_) \
  777. FT_INTERNAL(free_name,free_name_) \
  778. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_hdmx_stub,load_hdmx_stub_) \
  779. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_hdmx_stub,free_hdmx_stub_) \
  780. FT_INTERNAL(load_kern,load_kern_) \
  781. FT_INTERNAL(load_gasp,load_gasp_) \
  782. FT_INTERNAL(load_pclt,load_pclt_) \
  783. FT_INTERNAL(load_bhed,load_bhed_) \
  784. FT_DEFINE_DRIVERS_OLD_INTERNAL(set_sbit_strike_stub,set_sbit_strike_stub_) \
  785. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbits_stub,load_sbits_stub_) \
  786. FT_DEFINE_DRIVERS_OLD_INTERNAL(find_sbit_image,find_sbit_image_) \
  787. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbit_metrics,load_sbit_metrics_) \
  788. FT_INTERNAL(load_sbit_image,load_sbit_image_) \
  789. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_sbits_stub,free_sbits_stub_) \
  790. FT_INTERNAL(get_psname,get_psname_) \
  791. FT_INTERNAL(free_psnames,free_psnames_) \
  792. FT_DEFINE_DRIVERS_OLD_INTERNAL(load_charmap_stub,load_charmap_stub_) \
  793. FT_DEFINE_DRIVERS_OLD_INTERNAL(free_charmap_stub,free_charmap_stub_) \
  794. FT_INTERNAL(get_kerning,get_kerning_) \
  795. FT_INTERNAL(load_font_dir,load_font_dir_) \
  796. FT_INTERNAL(load_hmtx,load_hmtx_) \
  797. FT_INTERNAL(load_eblc,load_eblc_) \
  798. FT_INTERNAL(free_eblc,free_eblc_) \
  799. FT_INTERNAL(set_sbit_strike,set_sbit_strike_) \
  800. FT_INTERNAL(load_strike_metrics,load_strike_metrics_) \
  801. FT_INTERNAL(get_metrics,get_metrics_) \
  802. }
  803. #endif /* FT_CONFIG_OPTION_PIC */
  804. FT_END_HEADER
  805. #endif /* __SFNT_H__ */
  806. /* END */