tttables.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. /****************************************************************************
  2. *
  3. * tttables.h
  4. *
  5. * Basic SFNT/TrueType tables definitions and interface
  6. * (specification only).
  7. *
  8. * Copyright (C) 1996-2023 by
  9. * David Turner, Robert Wilhelm, and Werner Lemberg.
  10. *
  11. * This file is part of the FreeType project, and may only be used,
  12. * modified, and distributed under the terms of the FreeType project
  13. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  14. * this file you indicate that you have read the license and
  15. * understand and accept it fully.
  16. *
  17. */
  18. #ifndef TTTABLES_H_
  19. #define TTTABLES_H_
  20. #include <freetype/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. * truetype_tables
  31. *
  32. * @title:
  33. * TrueType Tables
  34. *
  35. * @abstract:
  36. * TrueType-specific table types and functions.
  37. *
  38. * @description:
  39. * This section contains definitions of some basic tables specific to
  40. * TrueType and OpenType as well as some routines used to access and
  41. * process them.
  42. *
  43. * @order:
  44. * TT_Header
  45. * TT_HoriHeader
  46. * TT_VertHeader
  47. * TT_OS2
  48. * TT_Postscript
  49. * TT_PCLT
  50. * TT_MaxProfile
  51. *
  52. * FT_Sfnt_Tag
  53. * FT_Get_Sfnt_Table
  54. * FT_Load_Sfnt_Table
  55. * FT_Sfnt_Table_Info
  56. *
  57. * FT_Get_CMap_Language_ID
  58. * FT_Get_CMap_Format
  59. *
  60. * FT_PARAM_TAG_UNPATENTED_HINTING
  61. *
  62. */
  63. /**************************************************************************
  64. *
  65. * @struct:
  66. * TT_Header
  67. *
  68. * @description:
  69. * A structure to model a TrueType font header table. All fields follow
  70. * the OpenType specification. The 64-bit timestamps are stored in
  71. * two-element arrays `Created` and `Modified`, first the upper then
  72. * the lower 32~bits.
  73. */
  74. typedef struct TT_Header_
  75. {
  76. FT_Fixed Table_Version;
  77. FT_Fixed Font_Revision;
  78. FT_Long CheckSum_Adjust;
  79. FT_Long Magic_Number;
  80. FT_UShort Flags;
  81. FT_UShort Units_Per_EM;
  82. FT_ULong Created [2];
  83. FT_ULong Modified[2];
  84. FT_Short xMin;
  85. FT_Short yMin;
  86. FT_Short xMax;
  87. FT_Short yMax;
  88. FT_UShort Mac_Style;
  89. FT_UShort Lowest_Rec_PPEM;
  90. FT_Short Font_Direction;
  91. FT_Short Index_To_Loc_Format;
  92. FT_Short Glyph_Data_Format;
  93. } TT_Header;
  94. /**************************************************************************
  95. *
  96. * @struct:
  97. * TT_HoriHeader
  98. *
  99. * @description:
  100. * A structure to model a TrueType horizontal header, the 'hhea' table,
  101. * as well as the corresponding horizontal metrics table, 'hmtx'.
  102. *
  103. * @fields:
  104. * Version ::
  105. * The table version.
  106. *
  107. * Ascender ::
  108. * The font's ascender, i.e., the distance from the baseline to the
  109. * top-most of all glyph points found in the font.
  110. *
  111. * This value is invalid in many fonts, as it is usually set by the
  112. * font designer, and often reflects only a portion of the glyphs found
  113. * in the font (maybe ASCII).
  114. *
  115. * You should use the `sTypoAscender` field of the 'OS/2' table instead
  116. * if you want the correct one.
  117. *
  118. * Descender ::
  119. * The font's descender, i.e., the distance from the baseline to the
  120. * bottom-most of all glyph points found in the font. It is negative.
  121. *
  122. * This value is invalid in many fonts, as it is usually set by the
  123. * font designer, and often reflects only a portion of the glyphs found
  124. * in the font (maybe ASCII).
  125. *
  126. * You should use the `sTypoDescender` field of the 'OS/2' table
  127. * instead if you want the correct one.
  128. *
  129. * Line_Gap ::
  130. * The font's line gap, i.e., the distance to add to the ascender and
  131. * descender to get the BTB, i.e., the baseline-to-baseline distance
  132. * for the font.
  133. *
  134. * advance_Width_Max ::
  135. * This field is the maximum of all advance widths found in the font.
  136. * It can be used to compute the maximum width of an arbitrary string
  137. * of text.
  138. *
  139. * min_Left_Side_Bearing ::
  140. * The minimum left side bearing of all glyphs within the font.
  141. *
  142. * min_Right_Side_Bearing ::
  143. * The minimum right side bearing of all glyphs within the font.
  144. *
  145. * xMax_Extent ::
  146. * The maximum horizontal extent (i.e., the 'width' of a glyph's
  147. * bounding box) for all glyphs in the font.
  148. *
  149. * caret_Slope_Rise ::
  150. * The rise coefficient of the cursor's slope of the cursor
  151. * (slope=rise/run).
  152. *
  153. * caret_Slope_Run ::
  154. * The run coefficient of the cursor's slope.
  155. *
  156. * caret_Offset ::
  157. * The cursor's offset for slanted fonts.
  158. *
  159. * Reserved ::
  160. * 8~reserved bytes.
  161. *
  162. * metric_Data_Format ::
  163. * Always~0.
  164. *
  165. * number_Of_HMetrics ::
  166. * Number of HMetrics entries in the 'hmtx' table -- this value can be
  167. * smaller than the total number of glyphs in the font.
  168. *
  169. * long_metrics ::
  170. * A pointer into the 'hmtx' table.
  171. *
  172. * short_metrics ::
  173. * A pointer into the 'hmtx' table.
  174. *
  175. * @note:
  176. * For an OpenType variation font, the values of the following fields can
  177. * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
  178. * the font contains an 'MVAR' table: `caret_Slope_Rise`,
  179. * `caret_Slope_Run`, and `caret_Offset`.
  180. */
  181. typedef struct TT_HoriHeader_
  182. {
  183. FT_Fixed Version;
  184. FT_Short Ascender;
  185. FT_Short Descender;
  186. FT_Short Line_Gap;
  187. FT_UShort advance_Width_Max; /* advance width maximum */
  188. FT_Short min_Left_Side_Bearing; /* minimum left-sb */
  189. FT_Short min_Right_Side_Bearing; /* minimum right-sb */
  190. FT_Short xMax_Extent; /* xmax extents */
  191. FT_Short caret_Slope_Rise;
  192. FT_Short caret_Slope_Run;
  193. FT_Short caret_Offset;
  194. FT_Short Reserved[4];
  195. FT_Short metric_Data_Format;
  196. FT_UShort number_Of_HMetrics;
  197. /* The following fields are not defined by the OpenType specification */
  198. /* but they are used to connect the metrics header to the relevant */
  199. /* 'hmtx' table. */
  200. void* long_metrics;
  201. void* short_metrics;
  202. } TT_HoriHeader;
  203. /**************************************************************************
  204. *
  205. * @struct:
  206. * TT_VertHeader
  207. *
  208. * @description:
  209. * A structure used to model a TrueType vertical header, the 'vhea'
  210. * table, as well as the corresponding vertical metrics table, 'vmtx'.
  211. *
  212. * @fields:
  213. * Version ::
  214. * The table version.
  215. *
  216. * Ascender ::
  217. * The font's ascender, i.e., the distance from the baseline to the
  218. * top-most of all glyph points found in the font.
  219. *
  220. * This value is invalid in many fonts, as it is usually set by the
  221. * font designer, and often reflects only a portion of the glyphs found
  222. * in the font (maybe ASCII).
  223. *
  224. * You should use the `sTypoAscender` field of the 'OS/2' table instead
  225. * if you want the correct one.
  226. *
  227. * Descender ::
  228. * The font's descender, i.e., the distance from the baseline to the
  229. * bottom-most of all glyph points found in the font. It is negative.
  230. *
  231. * This value is invalid in many fonts, as it is usually set by the
  232. * font designer, and often reflects only a portion of the glyphs found
  233. * in the font (maybe ASCII).
  234. *
  235. * You should use the `sTypoDescender` field of the 'OS/2' table
  236. * instead if you want the correct one.
  237. *
  238. * Line_Gap ::
  239. * The font's line gap, i.e., the distance to add to the ascender and
  240. * descender to get the BTB, i.e., the baseline-to-baseline distance
  241. * for the font.
  242. *
  243. * advance_Height_Max ::
  244. * This field is the maximum of all advance heights found in the font.
  245. * It can be used to compute the maximum height of an arbitrary string
  246. * of text.
  247. *
  248. * min_Top_Side_Bearing ::
  249. * The minimum top side bearing of all glyphs within the font.
  250. *
  251. * min_Bottom_Side_Bearing ::
  252. * The minimum bottom side bearing of all glyphs within the font.
  253. *
  254. * yMax_Extent ::
  255. * The maximum vertical extent (i.e., the 'height' of a glyph's
  256. * bounding box) for all glyphs in the font.
  257. *
  258. * caret_Slope_Rise ::
  259. * The rise coefficient of the cursor's slope of the cursor
  260. * (slope=rise/run).
  261. *
  262. * caret_Slope_Run ::
  263. * The run coefficient of the cursor's slope.
  264. *
  265. * caret_Offset ::
  266. * The cursor's offset for slanted fonts.
  267. *
  268. * Reserved ::
  269. * 8~reserved bytes.
  270. *
  271. * metric_Data_Format ::
  272. * Always~0.
  273. *
  274. * number_Of_VMetrics ::
  275. * Number of VMetrics entries in the 'vmtx' table -- this value can be
  276. * smaller than the total number of glyphs in the font.
  277. *
  278. * long_metrics ::
  279. * A pointer into the 'vmtx' table.
  280. *
  281. * short_metrics ::
  282. * A pointer into the 'vmtx' table.
  283. *
  284. * @note:
  285. * For an OpenType variation font, the values of the following fields can
  286. * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
  287. * the font contains an 'MVAR' table: `Ascender`, `Descender`,
  288. * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`.
  289. */
  290. typedef struct TT_VertHeader_
  291. {
  292. FT_Fixed Version;
  293. FT_Short Ascender;
  294. FT_Short Descender;
  295. FT_Short Line_Gap;
  296. FT_UShort advance_Height_Max; /* advance height maximum */
  297. FT_Short min_Top_Side_Bearing; /* minimum top-sb */
  298. FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */
  299. FT_Short yMax_Extent; /* ymax extents */
  300. FT_Short caret_Slope_Rise;
  301. FT_Short caret_Slope_Run;
  302. FT_Short caret_Offset;
  303. FT_Short Reserved[4];
  304. FT_Short metric_Data_Format;
  305. FT_UShort number_Of_VMetrics;
  306. /* The following fields are not defined by the OpenType specification */
  307. /* but they are used to connect the metrics header to the relevant */
  308. /* 'vmtx' table. */
  309. void* long_metrics;
  310. void* short_metrics;
  311. } TT_VertHeader;
  312. /**************************************************************************
  313. *
  314. * @struct:
  315. * TT_OS2
  316. *
  317. * @description:
  318. * A structure to model a TrueType 'OS/2' table. All fields comply to
  319. * the OpenType specification.
  320. *
  321. * Note that we now support old Mac fonts that do not include an 'OS/2'
  322. * table. In this case, the `version` field is always set to 0xFFFF.
  323. *
  324. * @note:
  325. * For an OpenType variation font, the values of the following fields can
  326. * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
  327. * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`,
  328. * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`,
  329. * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`,
  330. * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`,
  331. * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`,
  332. * `ySuperscriptYOffset`, and `ySuperscriptYSize`.
  333. *
  334. * Possible values for bits in the `ulUnicodeRangeX` fields are given by
  335. * the @TT_UCR_XXX macros.
  336. */
  337. typedef struct TT_OS2_
  338. {
  339. FT_UShort version; /* 0x0001 - more or 0xFFFF */
  340. FT_Short xAvgCharWidth;
  341. FT_UShort usWeightClass;
  342. FT_UShort usWidthClass;
  343. FT_UShort fsType;
  344. FT_Short ySubscriptXSize;
  345. FT_Short ySubscriptYSize;
  346. FT_Short ySubscriptXOffset;
  347. FT_Short ySubscriptYOffset;
  348. FT_Short ySuperscriptXSize;
  349. FT_Short ySuperscriptYSize;
  350. FT_Short ySuperscriptXOffset;
  351. FT_Short ySuperscriptYOffset;
  352. FT_Short yStrikeoutSize;
  353. FT_Short yStrikeoutPosition;
  354. FT_Short sFamilyClass;
  355. FT_Byte panose[10];
  356. FT_ULong ulUnicodeRange1; /* Bits 0-31 */
  357. FT_ULong ulUnicodeRange2; /* Bits 32-63 */
  358. FT_ULong ulUnicodeRange3; /* Bits 64-95 */
  359. FT_ULong ulUnicodeRange4; /* Bits 96-127 */
  360. FT_Char achVendID[4];
  361. FT_UShort fsSelection;
  362. FT_UShort usFirstCharIndex;
  363. FT_UShort usLastCharIndex;
  364. FT_Short sTypoAscender;
  365. FT_Short sTypoDescender;
  366. FT_Short sTypoLineGap;
  367. FT_UShort usWinAscent;
  368. FT_UShort usWinDescent;
  369. /* only version 1 and higher: */
  370. FT_ULong ulCodePageRange1; /* Bits 0-31 */
  371. FT_ULong ulCodePageRange2; /* Bits 32-63 */
  372. /* only version 2 and higher: */
  373. FT_Short sxHeight;
  374. FT_Short sCapHeight;
  375. FT_UShort usDefaultChar;
  376. FT_UShort usBreakChar;
  377. FT_UShort usMaxContext;
  378. /* only version 5 and higher: */
  379. FT_UShort usLowerOpticalPointSize; /* in twips (1/20 points) */
  380. FT_UShort usUpperOpticalPointSize; /* in twips (1/20 points) */
  381. } TT_OS2;
  382. /**************************************************************************
  383. *
  384. * @struct:
  385. * TT_Postscript
  386. *
  387. * @description:
  388. * A structure to model a TrueType 'post' table. All fields comply to
  389. * the OpenType specification. This structure does not reference a
  390. * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve
  391. * them.
  392. *
  393. * @note:
  394. * For an OpenType variation font, the values of the following fields can
  395. * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
  396. * the font contains an 'MVAR' table: `underlinePosition` and
  397. * `underlineThickness`.
  398. */
  399. typedef struct TT_Postscript_
  400. {
  401. FT_Fixed FormatType;
  402. FT_Fixed italicAngle;
  403. FT_Short underlinePosition;
  404. FT_Short underlineThickness;
  405. FT_ULong isFixedPitch;
  406. FT_ULong minMemType42;
  407. FT_ULong maxMemType42;
  408. FT_ULong minMemType1;
  409. FT_ULong maxMemType1;
  410. /* Glyph names follow in the 'post' table, but we don't */
  411. /* load them by default. */
  412. } TT_Postscript;
  413. /**************************************************************************
  414. *
  415. * @struct:
  416. * TT_PCLT
  417. *
  418. * @description:
  419. * A structure to model a TrueType 'PCLT' table. All fields comply to
  420. * the OpenType specification.
  421. */
  422. typedef struct TT_PCLT_
  423. {
  424. FT_Fixed Version;
  425. FT_ULong FontNumber;
  426. FT_UShort Pitch;
  427. FT_UShort xHeight;
  428. FT_UShort Style;
  429. FT_UShort TypeFamily;
  430. FT_UShort CapHeight;
  431. FT_UShort SymbolSet;
  432. FT_Char TypeFace[16];
  433. FT_Char CharacterComplement[8];
  434. FT_Char FileName[6];
  435. FT_Char StrokeWeight;
  436. FT_Char WidthType;
  437. FT_Byte SerifStyle;
  438. FT_Byte Reserved;
  439. } TT_PCLT;
  440. /**************************************************************************
  441. *
  442. * @struct:
  443. * TT_MaxProfile
  444. *
  445. * @description:
  446. * The maximum profile ('maxp') table contains many max values, which can
  447. * be used to pre-allocate arrays for speeding up glyph loading and
  448. * hinting.
  449. *
  450. * @fields:
  451. * version ::
  452. * The version number.
  453. *
  454. * numGlyphs ::
  455. * The number of glyphs in this TrueType font.
  456. *
  457. * maxPoints ::
  458. * The maximum number of points in a non-composite TrueType glyph. See
  459. * also `maxCompositePoints`.
  460. *
  461. * maxContours ::
  462. * The maximum number of contours in a non-composite TrueType glyph.
  463. * See also `maxCompositeContours`.
  464. *
  465. * maxCompositePoints ::
  466. * The maximum number of points in a composite TrueType glyph. See
  467. * also `maxPoints`.
  468. *
  469. * maxCompositeContours ::
  470. * The maximum number of contours in a composite TrueType glyph. See
  471. * also `maxContours`.
  472. *
  473. * maxZones ::
  474. * The maximum number of zones used for glyph hinting.
  475. *
  476. * maxTwilightPoints ::
  477. * The maximum number of points in the twilight zone used for glyph
  478. * hinting.
  479. *
  480. * maxStorage ::
  481. * The maximum number of elements in the storage area used for glyph
  482. * hinting.
  483. *
  484. * maxFunctionDefs ::
  485. * The maximum number of function definitions in the TrueType bytecode
  486. * for this font.
  487. *
  488. * maxInstructionDefs ::
  489. * The maximum number of instruction definitions in the TrueType
  490. * bytecode for this font.
  491. *
  492. * maxStackElements ::
  493. * The maximum number of stack elements used during bytecode
  494. * interpretation.
  495. *
  496. * maxSizeOfInstructions ::
  497. * The maximum number of TrueType opcodes used for glyph hinting.
  498. *
  499. * maxComponentElements ::
  500. * The maximum number of simple (i.e., non-composite) glyphs in a
  501. * composite glyph.
  502. *
  503. * maxComponentDepth ::
  504. * The maximum nesting depth of composite glyphs.
  505. *
  506. * @note:
  507. * This structure is only used during font loading.
  508. */
  509. typedef struct TT_MaxProfile_
  510. {
  511. FT_Fixed version;
  512. FT_UShort numGlyphs;
  513. FT_UShort maxPoints;
  514. FT_UShort maxContours;
  515. FT_UShort maxCompositePoints;
  516. FT_UShort maxCompositeContours;
  517. FT_UShort maxZones;
  518. FT_UShort maxTwilightPoints;
  519. FT_UShort maxStorage;
  520. FT_UShort maxFunctionDefs;
  521. FT_UShort maxInstructionDefs;
  522. FT_UShort maxStackElements;
  523. FT_UShort maxSizeOfInstructions;
  524. FT_UShort maxComponentElements;
  525. FT_UShort maxComponentDepth;
  526. } TT_MaxProfile;
  527. /**************************************************************************
  528. *
  529. * @enum:
  530. * FT_Sfnt_Tag
  531. *
  532. * @description:
  533. * An enumeration to specify indices of SFNT tables loaded and parsed by
  534. * FreeType during initialization of an SFNT font. Used in the
  535. * @FT_Get_Sfnt_Table API function.
  536. *
  537. * @values:
  538. * FT_SFNT_HEAD ::
  539. * To access the font's @TT_Header structure.
  540. *
  541. * FT_SFNT_MAXP ::
  542. * To access the font's @TT_MaxProfile structure.
  543. *
  544. * FT_SFNT_OS2 ::
  545. * To access the font's @TT_OS2 structure.
  546. *
  547. * FT_SFNT_HHEA ::
  548. * To access the font's @TT_HoriHeader structure.
  549. *
  550. * FT_SFNT_VHEA ::
  551. * To access the font's @TT_VertHeader structure.
  552. *
  553. * FT_SFNT_POST ::
  554. * To access the font's @TT_Postscript structure.
  555. *
  556. * FT_SFNT_PCLT ::
  557. * To access the font's @TT_PCLT structure.
  558. */
  559. typedef enum FT_Sfnt_Tag_
  560. {
  561. FT_SFNT_HEAD,
  562. FT_SFNT_MAXP,
  563. FT_SFNT_OS2,
  564. FT_SFNT_HHEA,
  565. FT_SFNT_VHEA,
  566. FT_SFNT_POST,
  567. FT_SFNT_PCLT,
  568. FT_SFNT_MAX
  569. } FT_Sfnt_Tag;
  570. /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */
  571. /* values instead */
  572. #define ft_sfnt_head FT_SFNT_HEAD
  573. #define ft_sfnt_maxp FT_SFNT_MAXP
  574. #define ft_sfnt_os2 FT_SFNT_OS2
  575. #define ft_sfnt_hhea FT_SFNT_HHEA
  576. #define ft_sfnt_vhea FT_SFNT_VHEA
  577. #define ft_sfnt_post FT_SFNT_POST
  578. #define ft_sfnt_pclt FT_SFNT_PCLT
  579. /**************************************************************************
  580. *
  581. * @function:
  582. * FT_Get_Sfnt_Table
  583. *
  584. * @description:
  585. * Return a pointer to a given SFNT table stored within a face.
  586. *
  587. * @input:
  588. * face ::
  589. * A handle to the source.
  590. *
  591. * tag ::
  592. * The index of the SFNT table.
  593. *
  594. * @return:
  595. * A type-less pointer to the table. This will be `NULL` in case of
  596. * error, or if the corresponding table was not found **OR** loaded from
  597. * the file.
  598. *
  599. * Use a typecast according to `tag` to access the structure elements.
  600. *
  601. * @note:
  602. * The table is owned by the face object and disappears with it.
  603. *
  604. * This function is only useful to access SFNT tables that are loaded by
  605. * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a
  606. * list.
  607. *
  608. * @example:
  609. * Here is an example demonstrating access to the 'vhea' table.
  610. *
  611. * ```
  612. * TT_VertHeader* vert_header;
  613. *
  614. *
  615. * vert_header =
  616. * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA );
  617. * ```
  618. */
  619. FT_EXPORT( void* )
  620. FT_Get_Sfnt_Table( FT_Face face,
  621. FT_Sfnt_Tag tag );
  622. /**************************************************************************
  623. *
  624. * @function:
  625. * FT_Load_Sfnt_Table
  626. *
  627. * @description:
  628. * Load any SFNT font table into client memory.
  629. *
  630. * @input:
  631. * face ::
  632. * A handle to the source face.
  633. *
  634. * tag ::
  635. * The four-byte tag of the table to load. Use value~0 if you want to
  636. * access the whole font file. Otherwise, you can use one of the
  637. * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
  638. * one with @FT_MAKE_TAG.
  639. *
  640. * offset ::
  641. * The starting offset in the table (or file if tag~==~0).
  642. *
  643. * @output:
  644. * buffer ::
  645. * The target buffer address. The client must ensure that the memory
  646. * array is big enough to hold the data.
  647. *
  648. * @inout:
  649. * length ::
  650. * If the `length` parameter is `NULL`, try to load the whole table.
  651. * Return an error code if it fails.
  652. *
  653. * Else, if `*length` is~0, exit immediately while returning the
  654. * table's (or file) full size in it.
  655. *
  656. * Else the number of bytes to read from the table or file, from the
  657. * starting offset.
  658. *
  659. * @return:
  660. * FreeType error code. 0~means success.
  661. *
  662. * @note:
  663. * If you need to determine the table's length you should first call this
  664. * function with `*length` set to~0, as in the following example:
  665. *
  666. * ```
  667. * FT_ULong length = 0;
  668. *
  669. *
  670. * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
  671. * if ( error ) { ... table does not exist ... }
  672. *
  673. * buffer = malloc( length );
  674. * if ( buffer == NULL ) { ... not enough memory ... }
  675. *
  676. * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
  677. * if ( error ) { ... could not load table ... }
  678. * ```
  679. *
  680. * Note that structures like @TT_Header or @TT_OS2 can't be used with
  681. * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that
  682. * those structures depend on the processor architecture, with varying
  683. * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
  684. *
  685. */
  686. FT_EXPORT( FT_Error )
  687. FT_Load_Sfnt_Table( FT_Face face,
  688. FT_ULong tag,
  689. FT_Long offset,
  690. FT_Byte* buffer,
  691. FT_ULong* length );
  692. /**************************************************************************
  693. *
  694. * @function:
  695. * FT_Sfnt_Table_Info
  696. *
  697. * @description:
  698. * Return information on an SFNT table.
  699. *
  700. * @input:
  701. * face ::
  702. * A handle to the source face.
  703. *
  704. * table_index ::
  705. * The index of an SFNT table. The function returns
  706. * FT_Err_Table_Missing for an invalid value.
  707. *
  708. * @inout:
  709. * tag ::
  710. * The name tag of the SFNT table. If the value is `NULL`,
  711. * `table_index` is ignored, and `length` returns the number of SFNT
  712. * tables in the font.
  713. *
  714. * @output:
  715. * length ::
  716. * The length of the SFNT table (or the number of SFNT tables,
  717. * depending on `tag`).
  718. *
  719. * @return:
  720. * FreeType error code. 0~means success.
  721. *
  722. * @note:
  723. * While parsing fonts, FreeType handles SFNT tables with length zero as
  724. * missing.
  725. *
  726. */
  727. FT_EXPORT( FT_Error )
  728. FT_Sfnt_Table_Info( FT_Face face,
  729. FT_UInt table_index,
  730. FT_ULong *tag,
  731. FT_ULong *length );
  732. /**************************************************************************
  733. *
  734. * @function:
  735. * FT_Get_CMap_Language_ID
  736. *
  737. * @description:
  738. * Return cmap language ID as specified in the OpenType standard.
  739. * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H.
  740. *
  741. * @input:
  742. * charmap ::
  743. * The target charmap.
  744. *
  745. * @return:
  746. * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT
  747. * face, just return~0 as the default value.
  748. *
  749. * For a format~14 cmap (to access Unicode IVS), the return value is
  750. * 0xFFFFFFFF.
  751. */
  752. FT_EXPORT( FT_ULong )
  753. FT_Get_CMap_Language_ID( FT_CharMap charmap );
  754. /**************************************************************************
  755. *
  756. * @function:
  757. * FT_Get_CMap_Format
  758. *
  759. * @description:
  760. * Return the format of an SFNT 'cmap' table.
  761. *
  762. * @input:
  763. * charmap ::
  764. * The target charmap.
  765. *
  766. * @return:
  767. * The format of `charmap`. If `charmap` doesn't belong to an SFNT face,
  768. * return -1.
  769. */
  770. FT_EXPORT( FT_Long )
  771. FT_Get_CMap_Format( FT_CharMap charmap );
  772. /* */
  773. FT_END_HEADER
  774. #endif /* TTTABLES_H_ */
  775. /* END */