ftotval.h 5.2 KB

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