ftgxval.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /***************************************************************************/
  2. /* */
  3. /* ftgxval.h */
  4. /* */
  5. /* FreeType API for validating TrueTypeGX/AAT tables (specification). */
  6. /* */
  7. /* Copyright 2004-2006, 2013 by */
  8. /* Masatake YAMATO, Redhat K.K, */
  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. /***************************************************************************/
  19. /* */
  20. /* gxvalid is derived from both gxlayout module and otvalid module. */
  21. /* Development of gxlayout is supported by the Information-technology */
  22. /* Promotion Agency(IPA), Japan. */
  23. /* */
  24. /***************************************************************************/
  25. #ifndef __FTGXVAL_H__
  26. #define __FTGXVAL_H__
  27. #include <ft2build.h>
  28. #include FT_FREETYPE_H
  29. #ifdef FREETYPE_H
  30. #error "freetype.h of FreeType 1 has been loaded!"
  31. #error "Please fix the directory search order for header files"
  32. #error "so that freetype.h of FreeType 2 is found first."
  33. #endif
  34. FT_BEGIN_HEADER
  35. /*************************************************************************/
  36. /* */
  37. /* <Section> */
  38. /* gx_validation */
  39. /* */
  40. /* <Title> */
  41. /* TrueTypeGX/AAT Validation */
  42. /* */
  43. /* <Abstract> */
  44. /* An API to validate TrueTypeGX/AAT tables. */
  45. /* */
  46. /* <Description> */
  47. /* This section contains the declaration of functions to validate */
  48. /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */
  49. /* trak, prop, lcar). */
  50. /* */
  51. /* <Order> */
  52. /* FT_TrueTypeGX_Validate */
  53. /* FT_TrueTypeGX_Free */
  54. /* */
  55. /* FT_ClassicKern_Validate */
  56. /* FT_ClassicKern_Free */
  57. /* */
  58. /* FT_VALIDATE_GX_LENGTH */
  59. /* FT_VALIDATE_GXXXX */
  60. /* FT_VALIDATE_CKERNXXX */
  61. /* */
  62. /*************************************************************************/
  63. /*************************************************************************/
  64. /* */
  65. /* */
  66. /* Warning: Use FT_VALIDATE_XXX to validate a table. */
  67. /* Following definitions are for gxvalid developers. */
  68. /* */
  69. /* */
  70. /*************************************************************************/
  71. #define FT_VALIDATE_feat_INDEX 0
  72. #define FT_VALIDATE_mort_INDEX 1
  73. #define FT_VALIDATE_morx_INDEX 2
  74. #define FT_VALIDATE_bsln_INDEX 3
  75. #define FT_VALIDATE_just_INDEX 4
  76. #define FT_VALIDATE_kern_INDEX 5
  77. #define FT_VALIDATE_opbd_INDEX 6
  78. #define FT_VALIDATE_trak_INDEX 7
  79. #define FT_VALIDATE_prop_INDEX 8
  80. #define FT_VALIDATE_lcar_INDEX 9
  81. #define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX
  82. /*************************************************************************
  83. *
  84. * @macro:
  85. * FT_VALIDATE_GX_LENGTH
  86. *
  87. * @description:
  88. * The number of tables checked in this module. Use it as a parameter
  89. * for the `table-length' argument of function @FT_TrueTypeGX_Validate.
  90. */
  91. #define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1)
  92. /* */
  93. /* Up to 0x1000 is used by otvalid.
  94. Ox2xxx is reserved for feature OT extension. */
  95. #define FT_VALIDATE_GX_START 0x4000
  96. #define FT_VALIDATE_GX_BITFIELD( tag ) \
  97. ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
  98. /**********************************************************************
  99. *
  100. * @enum:
  101. * FT_VALIDATE_GXXXX
  102. *
  103. * @description:
  104. * A list of bit-field constants used with @FT_TrueTypeGX_Validate to
  105. * indicate which TrueTypeGX/AAT Type tables should be validated.
  106. *
  107. * @values:
  108. * FT_VALIDATE_feat ::
  109. * Validate `feat' table.
  110. *
  111. * FT_VALIDATE_mort ::
  112. * Validate `mort' table.
  113. *
  114. * FT_VALIDATE_morx ::
  115. * Validate `morx' table.
  116. *
  117. * FT_VALIDATE_bsln ::
  118. * Validate `bsln' table.
  119. *
  120. * FT_VALIDATE_just ::
  121. * Validate `just' table.
  122. *
  123. * FT_VALIDATE_kern ::
  124. * Validate `kern' table.
  125. *
  126. * FT_VALIDATE_opbd ::
  127. * Validate `opbd' table.
  128. *
  129. * FT_VALIDATE_trak ::
  130. * Validate `trak' table.
  131. *
  132. * FT_VALIDATE_prop ::
  133. * Validate `prop' table.
  134. *
  135. * FT_VALIDATE_lcar ::
  136. * Validate `lcar' table.
  137. *
  138. * FT_VALIDATE_GX ::
  139. * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern,
  140. * opbd, trak, prop and lcar).
  141. *
  142. */
  143. #define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
  144. #define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
  145. #define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
  146. #define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
  147. #define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
  148. #define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
  149. #define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
  150. #define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
  151. #define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
  152. #define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
  153. #define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
  154. FT_VALIDATE_mort | \
  155. FT_VALIDATE_morx | \
  156. FT_VALIDATE_bsln | \
  157. FT_VALIDATE_just | \
  158. FT_VALIDATE_kern | \
  159. FT_VALIDATE_opbd | \
  160. FT_VALIDATE_trak | \
  161. FT_VALIDATE_prop | \
  162. FT_VALIDATE_lcar )
  163. /**********************************************************************
  164. *
  165. * @function:
  166. * FT_TrueTypeGX_Validate
  167. *
  168. * @description:
  169. * Validate various TrueTypeGX tables to assure that all offsets and
  170. * indices are valid. The idea is that a higher-level library that
  171. * actually does the text layout can access those tables without
  172. * error checking (which can be quite time consuming).
  173. *
  174. * @input:
  175. * face ::
  176. * A handle to the input face.
  177. *
  178. * validation_flags ::
  179. * A bit field that specifies the tables to be validated. See
  180. * @FT_VALIDATE_GXXXX for possible values.
  181. *
  182. * table_length ::
  183. * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH
  184. * should be passed.
  185. *
  186. * @output:
  187. * tables ::
  188. * The array where all validated sfnt tables are stored.
  189. * The array itself must be allocated by a client.
  190. *
  191. * @return:
  192. * FreeType error code. 0~means success.
  193. *
  194. * @note:
  195. * This function only works with TrueTypeGX fonts, returning an error
  196. * otherwise.
  197. *
  198. * After use, the application should deallocate the buffers pointed to by
  199. * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value
  200. * indicates that the table either doesn't exist in the font, the
  201. * application hasn't asked for validation, or the validator doesn't have
  202. * the ability to validate the sfnt table.
  203. */
  204. FT_EXPORT( FT_Error )
  205. FT_TrueTypeGX_Validate( FT_Face face,
  206. FT_UInt validation_flags,
  207. FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
  208. FT_UInt table_length );
  209. /**********************************************************************
  210. *
  211. * @function:
  212. * FT_TrueTypeGX_Free
  213. *
  214. * @description:
  215. * Free the buffer allocated by TrueTypeGX validator.
  216. *
  217. * @input:
  218. * face ::
  219. * A handle to the input face.
  220. *
  221. * table ::
  222. * The pointer to the buffer allocated by
  223. * @FT_TrueTypeGX_Validate.
  224. *
  225. * @note:
  226. * This function must be used to free the buffer allocated by
  227. * @FT_TrueTypeGX_Validate only.
  228. */
  229. FT_EXPORT( void )
  230. FT_TrueTypeGX_Free( FT_Face face,
  231. FT_Bytes table );
  232. /**********************************************************************
  233. *
  234. * @enum:
  235. * FT_VALIDATE_CKERNXXX
  236. *
  237. * @description:
  238. * A list of bit-field constants used with @FT_ClassicKern_Validate
  239. * to indicate the classic kern dialect or dialects. If the selected
  240. * type doesn't fit, @FT_ClassicKern_Validate regards the table as
  241. * invalid.
  242. *
  243. * @values:
  244. * FT_VALIDATE_MS ::
  245. * Handle the `kern' table as a classic Microsoft kern table.
  246. *
  247. * FT_VALIDATE_APPLE ::
  248. * Handle the `kern' table as a classic Apple kern table.
  249. *
  250. * FT_VALIDATE_CKERN ::
  251. * Handle the `kern' as either classic Apple or Microsoft kern table.
  252. */
  253. #define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
  254. #define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
  255. #define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
  256. /**********************************************************************
  257. *
  258. * @function:
  259. * FT_ClassicKern_Validate
  260. *
  261. * @description:
  262. * Validate classic (16-bit format) kern table to assure that the offsets
  263. * and indices are valid. The idea is that a higher-level library that
  264. * actually does the text layout can access those tables without error
  265. * checking (which can be quite time consuming).
  266. *
  267. * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both
  268. * the new 32-bit format and the classic 16-bit format, while
  269. * FT_ClassicKern_Validate only supports the classic 16-bit format.
  270. *
  271. * @input:
  272. * face ::
  273. * A handle to the input face.
  274. *
  275. * validation_flags ::
  276. * A bit field that specifies the dialect to be validated. See
  277. * @FT_VALIDATE_CKERNXXX for possible values.
  278. *
  279. * @output:
  280. * ckern_table ::
  281. * A pointer to the kern table.
  282. *
  283. * @return:
  284. * FreeType error code. 0~means success.
  285. *
  286. * @note:
  287. * After use, the application should deallocate the buffers pointed to by
  288. * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value
  289. * indicates that the table doesn't exist in the font.
  290. */
  291. FT_EXPORT( FT_Error )
  292. FT_ClassicKern_Validate( FT_Face face,
  293. FT_UInt validation_flags,
  294. FT_Bytes *ckern_table );
  295. /**********************************************************************
  296. *
  297. * @function:
  298. * FT_ClassicKern_Free
  299. *
  300. * @description:
  301. * Free the buffer allocated by classic Kern validator.
  302. *
  303. * @input:
  304. * face ::
  305. * A handle to the input face.
  306. *
  307. * table ::
  308. * The pointer to the buffer that is allocated by
  309. * @FT_ClassicKern_Validate.
  310. *
  311. * @note:
  312. * This function must be used to free the buffer allocated by
  313. * @FT_ClassicKern_Validate only.
  314. */
  315. FT_EXPORT( void )
  316. FT_ClassicKern_Free( FT_Face face,
  317. FT_Bytes table );
  318. /* */
  319. FT_END_HEADER
  320. #endif /* __FTGXVAL_H__ */
  321. /* END */