ftotval.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /***************************************************************************/
  2. /* */
  3. /* ftotval.h */
  4. /* */
  5. /* FreeType API for validating OpenType tables (specification). */
  6. /* */
  7. /* Copyright 2004-2007, 2013, 2014 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. /***************************************************************************/
  18. /* */
  19. /* */
  20. /* Warning: This module might be moved to a different library in the */
  21. /* future to avoid a tight dependency between FreeType and the */
  22. /* OpenType specification. */
  23. /* */
  24. /* */
  25. /***************************************************************************/
  26. #ifndef __FTOTVAL_H__
  27. #define __FTOTVAL_H__
  28. #include <ft2build.h>
  29. #include FT_FREETYPE_H
  30. #ifdef FREETYPE_H
  31. #error "freetype.h of FreeType 1 has been loaded!"
  32. #error "Please fix the directory search order for header files"
  33. #error "so that freetype.h of FreeType 2 is found first."
  34. #endif
  35. FT_BEGIN_HEADER
  36. /*************************************************************************/
  37. /* */
  38. /* <Section> */
  39. /* ot_validation */
  40. /* */
  41. /* <Title> */
  42. /* OpenType Validation */
  43. /* */
  44. /* <Abstract> */
  45. /* An API to validate OpenType tables. */
  46. /* */
  47. /* <Description> */
  48. /* This section contains the declaration of functions to validate */
  49. /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */
  50. /* */
  51. /* <Order> */
  52. /* FT_OpenType_Validate */
  53. /* FT_OpenType_Free */
  54. /* */
  55. /* FT_VALIDATE_OTXXX */
  56. /* */
  57. /*************************************************************************/
  58. /**********************************************************************
  59. *
  60. * @enum:
  61. * FT_VALIDATE_OTXXX
  62. *
  63. * @description:
  64. * A list of bit-field constants used with @FT_OpenType_Validate to
  65. * indicate which OpenType tables should be validated.
  66. *
  67. * @values:
  68. * FT_VALIDATE_BASE ::
  69. * Validate BASE table.
  70. *
  71. * FT_VALIDATE_GDEF ::
  72. * Validate GDEF table.
  73. *
  74. * FT_VALIDATE_GPOS ::
  75. * Validate GPOS table.
  76. *
  77. * FT_VALIDATE_GSUB ::
  78. * Validate GSUB table.
  79. *
  80. * FT_VALIDATE_JSTF ::
  81. * Validate JSTF table.
  82. *
  83. * FT_VALIDATE_MATH ::
  84. * Validate MATH table.
  85. *
  86. * FT_VALIDATE_OT ::
  87. * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
  88. *
  89. */
  90. #define FT_VALIDATE_BASE 0x0100
  91. #define FT_VALIDATE_GDEF 0x0200
  92. #define FT_VALIDATE_GPOS 0x0400
  93. #define FT_VALIDATE_GSUB 0x0800
  94. #define FT_VALIDATE_JSTF 0x1000
  95. #define FT_VALIDATE_MATH 0x2000
  96. #define FT_VALIDATE_OT FT_VALIDATE_BASE | \
  97. FT_VALIDATE_GDEF | \
  98. FT_VALIDATE_GPOS | \
  99. FT_VALIDATE_GSUB | \
  100. FT_VALIDATE_JSTF | \
  101. FT_VALIDATE_MATH
  102. /**********************************************************************
  103. *
  104. * @function:
  105. * FT_OpenType_Validate
  106. *
  107. * @description:
  108. * Validate various OpenType tables to assure that all offsets and
  109. * indices are valid. The idea is that a higher-level library that
  110. * actually does the text layout can access those tables without
  111. * error checking (which can be quite time consuming).
  112. *
  113. * @input:
  114. * face ::
  115. * A handle to the input face.
  116. *
  117. * validation_flags ::
  118. * A bit field that specifies the tables to be validated. See
  119. * @FT_VALIDATE_OTXXX for possible values.
  120. *
  121. * @output:
  122. * BASE_table ::
  123. * A pointer to the BASE table.
  124. *
  125. * GDEF_table ::
  126. * A pointer to the GDEF table.
  127. *
  128. * GPOS_table ::
  129. * A pointer to the GPOS table.
  130. *
  131. * GSUB_table ::
  132. * A pointer to the GSUB table.
  133. *
  134. * JSTF_table ::
  135. * A pointer to the JSTF table.
  136. *
  137. * @return:
  138. * FreeType error code. 0~means success.
  139. *
  140. * @note:
  141. * This function only works with OpenType fonts, returning an error
  142. * otherwise.
  143. *
  144. * After use, the application should deallocate the five tables with
  145. * @FT_OpenType_Free. A NULL value indicates that the table either
  146. * doesn't exist in the font, or the application hasn't asked for
  147. * validation.
  148. */
  149. FT_EXPORT( FT_Error )
  150. FT_OpenType_Validate( FT_Face face,
  151. FT_UInt validation_flags,
  152. FT_Bytes *BASE_table,
  153. FT_Bytes *GDEF_table,
  154. FT_Bytes *GPOS_table,
  155. FT_Bytes *GSUB_table,
  156. FT_Bytes *JSTF_table );
  157. /**********************************************************************
  158. *
  159. * @function:
  160. * FT_OpenType_Free
  161. *
  162. * @description:
  163. * Free the buffer allocated by OpenType validator.
  164. *
  165. * @input:
  166. * face ::
  167. * A handle to the input face.
  168. *
  169. * table ::
  170. * The pointer to the buffer that is allocated by
  171. * @FT_OpenType_Validate.
  172. *
  173. * @note:
  174. * This function must be used to free the buffer allocated by
  175. * @FT_OpenType_Validate only.
  176. */
  177. FT_EXPORT( void )
  178. FT_OpenType_Free( FT_Face face,
  179. FT_Bytes table );
  180. /* */
  181. FT_END_HEADER
  182. #endif /* __FTOTVAL_H__ */
  183. /* END */