ftotval.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /***************************************************************************/
  2. /* */
  3. /* ftotval.h */
  4. /* */
  5. /* FreeType API for validating OpenType tables (specification). */
  6. /* */
  7. /* Copyright 2004-2007, 2013 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. /*************************************************************************/
  52. /**********************************************************************
  53. *
  54. * @enum:
  55. * FT_VALIDATE_OTXXX
  56. *
  57. * @description:
  58. * A list of bit-field constants used with @FT_OpenType_Validate to
  59. * indicate which OpenType tables should be validated.
  60. *
  61. * @values:
  62. * FT_VALIDATE_BASE ::
  63. * Validate BASE table.
  64. *
  65. * FT_VALIDATE_GDEF ::
  66. * Validate GDEF table.
  67. *
  68. * FT_VALIDATE_GPOS ::
  69. * Validate GPOS table.
  70. *
  71. * FT_VALIDATE_GSUB ::
  72. * Validate GSUB table.
  73. *
  74. * FT_VALIDATE_JSTF ::
  75. * Validate JSTF table.
  76. *
  77. * FT_VALIDATE_MATH ::
  78. * Validate MATH table.
  79. *
  80. * FT_VALIDATE_OT ::
  81. * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
  82. *
  83. */
  84. #define FT_VALIDATE_BASE 0x0100
  85. #define FT_VALIDATE_GDEF 0x0200
  86. #define FT_VALIDATE_GPOS 0x0400
  87. #define FT_VALIDATE_GSUB 0x0800
  88. #define FT_VALIDATE_JSTF 0x1000
  89. #define FT_VALIDATE_MATH 0x2000
  90. #define FT_VALIDATE_OT FT_VALIDATE_BASE | \
  91. FT_VALIDATE_GDEF | \
  92. FT_VALIDATE_GPOS | \
  93. FT_VALIDATE_GSUB | \
  94. FT_VALIDATE_JSTF | \
  95. FT_VALIDATE_MATH
  96. /* */
  97. /**********************************************************************
  98. *
  99. * @function:
  100. * FT_OpenType_Validate
  101. *
  102. * @description:
  103. * Validate various OpenType tables to assure that all offsets and
  104. * indices are valid. The idea is that a higher-level library that
  105. * actually does the text layout can access those tables without
  106. * error checking (which can be quite time consuming).
  107. *
  108. * @input:
  109. * face ::
  110. * A handle to the input face.
  111. *
  112. * validation_flags ::
  113. * A bit field that specifies the tables to be validated. See
  114. * @FT_VALIDATE_OTXXX for possible values.
  115. *
  116. * @output:
  117. * BASE_table ::
  118. * A pointer to the BASE table.
  119. *
  120. * GDEF_table ::
  121. * A pointer to the GDEF table.
  122. *
  123. * GPOS_table ::
  124. * A pointer to the GPOS table.
  125. *
  126. * GSUB_table ::
  127. * A pointer to the GSUB table.
  128. *
  129. * JSTF_table ::
  130. * A pointer to the JSTF table.
  131. *
  132. * @return:
  133. * FreeType error code. 0~means success.
  134. *
  135. * @note:
  136. * This function only works with OpenType fonts, returning an error
  137. * otherwise.
  138. *
  139. * After use, the application should deallocate the five tables with
  140. * @FT_OpenType_Free. A NULL value indicates that the table either
  141. * doesn't exist in the font, or the application hasn't asked for
  142. * validation.
  143. */
  144. FT_EXPORT( FT_Error )
  145. FT_OpenType_Validate( FT_Face face,
  146. FT_UInt validation_flags,
  147. FT_Bytes *BASE_table,
  148. FT_Bytes *GDEF_table,
  149. FT_Bytes *GPOS_table,
  150. FT_Bytes *GSUB_table,
  151. FT_Bytes *JSTF_table );
  152. /* */
  153. /**********************************************************************
  154. *
  155. * @function:
  156. * FT_OpenType_Free
  157. *
  158. * @description:
  159. * Free the buffer allocated by OpenType validator.
  160. *
  161. * @input:
  162. * face ::
  163. * A handle to the input face.
  164. *
  165. * table ::
  166. * The pointer to the buffer that is allocated by
  167. * @FT_OpenType_Validate.
  168. *
  169. * @note:
  170. * This function must be used to free the buffer allocated by
  171. * @FT_OpenType_Validate only.
  172. */
  173. FT_EXPORT( void )
  174. FT_OpenType_Free( FT_Face face,
  175. FT_Bytes table );
  176. /* */
  177. FT_END_HEADER
  178. #endif /* __FTOTVAL_H__ */
  179. /* END */