ftgxval.h 12 KB

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