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