1 /***************************************************************************/
5 /* FreeType API for validating TrueTypeGX/AAT tables (specification). */
7 /* Copyright 2004-2015 by */
8 /* Masatake YAMATO, Redhat K.K, */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
17 /***************************************************************************/
19 /***************************************************************************/
21 /* gxvalid is derived from both gxlayout module and otvalid module. */
22 /* Development of gxlayout is supported by the Information-technology */
23 /* Promotion Agency(IPA), Japan. */
25 /***************************************************************************/
32 #include FT_FREETYPE_H
35 #error "freetype.h of FreeType 1 has been loaded!"
36 #error "Please fix the directory search order for header files"
37 #error "so that freetype.h of FreeType 2 is found first."
44 /*************************************************************************/
50 /* TrueTypeGX/AAT Validation */
53 /* An API to validate TrueTypeGX/AAT tables. */
56 /* This section contains the declaration of functions to validate */
57 /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */
58 /* trak, prop, lcar). */
61 /* FT_TrueTypeGX_Validate */
62 /* FT_TrueTypeGX_Free */
64 /* FT_ClassicKern_Validate */
65 /* FT_ClassicKern_Free */
67 /* FT_VALIDATE_GX_LENGTH */
68 /* FT_VALIDATE_GXXXX */
69 /* FT_VALIDATE_CKERNXXX */
71 /*************************************************************************/
73 /*************************************************************************/
76 /* Warning: Use FT_VALIDATE_XXX to validate a table. */
77 /* Following definitions are for gxvalid developers. */
80 /*************************************************************************/
82 #define FT_VALIDATE_feat_INDEX 0
83 #define FT_VALIDATE_mort_INDEX 1
84 #define FT_VALIDATE_morx_INDEX 2
85 #define FT_VALIDATE_bsln_INDEX 3
86 #define FT_VALIDATE_just_INDEX 4
87 #define FT_VALIDATE_kern_INDEX 5
88 #define FT_VALIDATE_opbd_INDEX 6
89 #define FT_VALIDATE_trak_INDEX 7
90 #define FT_VALIDATE_prop_INDEX 8
91 #define FT_VALIDATE_lcar_INDEX 9
92 #define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX
95 /*************************************************************************
98 * FT_VALIDATE_GX_LENGTH
101 * The number of tables checked in this module. Use it as a parameter
102 * for the `table-length' argument of function @FT_TrueTypeGX_Validate.
104 #define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1)
108 /* Up to 0x1000 is used by otvalid.
109 Ox2xxx is reserved for feature OT extension. */
110 #define FT_VALIDATE_GX_START 0x4000
111 #define FT_VALIDATE_GX_BITFIELD( tag ) \
112 ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
115 /**********************************************************************
121 * A list of bit-field constants used with @FT_TrueTypeGX_Validate to
122 * indicate which TrueTypeGX/AAT Type tables should be validated.
125 * FT_VALIDATE_feat ::
126 * Validate `feat' table.
128 * FT_VALIDATE_mort ::
129 * Validate `mort' table.
131 * FT_VALIDATE_morx ::
132 * Validate `morx' table.
134 * FT_VALIDATE_bsln ::
135 * Validate `bsln' table.
137 * FT_VALIDATE_just ::
138 * Validate `just' table.
140 * FT_VALIDATE_kern ::
141 * Validate `kern' table.
143 * FT_VALIDATE_opbd ::
144 * Validate `opbd' table.
146 * FT_VALIDATE_trak ::
147 * Validate `trak' table.
149 * FT_VALIDATE_prop ::
150 * Validate `prop' table.
152 * FT_VALIDATE_lcar ::
153 * Validate `lcar' table.
156 * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern,
157 * opbd, trak, prop and lcar).
161 #define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
162 #define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
163 #define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
164 #define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
165 #define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
166 #define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
167 #define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
168 #define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
169 #define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
170 #define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
172 #define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
184 /**********************************************************************
187 * FT_TrueTypeGX_Validate
190 * Validate various TrueTypeGX tables to assure that all offsets and
191 * indices are valid. The idea is that a higher-level library that
192 * actually does the text layout can access those tables without
193 * error checking (which can be quite time consuming).
197 * A handle to the input face.
199 * validation_flags ::
200 * A bit field that specifies the tables to be validated. See
201 * @FT_VALIDATE_GXXXX for possible values.
204 * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH
209 * The array where all validated sfnt tables are stored.
210 * The array itself must be allocated by a client.
213 * FreeType error code. 0~means success.
216 * This function only works with TrueTypeGX fonts, returning an error
219 * After use, the application should deallocate the buffers pointed to by
220 * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value
221 * indicates that the table either doesn't exist in the font, the
222 * application hasn't asked for validation, or the validator doesn't have
223 * the ability to validate the sfnt table.
225 FT_EXPORT( FT_Error
)
226 FT_TrueTypeGX_Validate( FT_Face face
,
227 FT_UInt validation_flags
,
228 FT_Bytes tables
[FT_VALIDATE_GX_LENGTH
],
229 FT_UInt table_length
);
232 /**********************************************************************
238 * Free the buffer allocated by TrueTypeGX validator.
242 * A handle to the input face.
245 * The pointer to the buffer allocated by
246 * @FT_TrueTypeGX_Validate.
249 * This function must be used to free the buffer allocated by
250 * @FT_TrueTypeGX_Validate only.
253 FT_TrueTypeGX_Free( FT_Face face
,
257 /**********************************************************************
260 * FT_VALIDATE_CKERNXXX
263 * A list of bit-field constants used with @FT_ClassicKern_Validate
264 * to indicate the classic kern dialect or dialects. If the selected
265 * type doesn't fit, @FT_ClassicKern_Validate regards the table as
270 * Handle the `kern' table as a classic Microsoft kern table.
272 * FT_VALIDATE_APPLE ::
273 * Handle the `kern' table as a classic Apple kern table.
275 * FT_VALIDATE_CKERN ::
276 * Handle the `kern' as either classic Apple or Microsoft kern table.
278 #define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
279 #define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
281 #define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
284 /**********************************************************************
287 * FT_ClassicKern_Validate
290 * Validate classic (16-bit format) kern table to assure that the offsets
291 * and indices are valid. The idea is that a higher-level library that
292 * actually does the text layout can access those tables without error
293 * checking (which can be quite time consuming).
295 * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both
296 * the new 32-bit format and the classic 16-bit format, while
297 * FT_ClassicKern_Validate only supports the classic 16-bit format.
301 * A handle to the input face.
303 * validation_flags ::
304 * A bit field that specifies the dialect to be validated. See
305 * @FT_VALIDATE_CKERNXXX for possible values.
309 * A pointer to the kern table.
312 * FreeType error code. 0~means success.
315 * After use, the application should deallocate the buffers pointed to by
316 * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value
317 * indicates that the table doesn't exist in the font.
319 FT_EXPORT( FT_Error
)
320 FT_ClassicKern_Validate( FT_Face face
,
321 FT_UInt validation_flags
,
322 FT_Bytes
*ckern_table
);
325 /**********************************************************************
328 * FT_ClassicKern_Free
331 * Free the buffer allocated by classic Kern validator.
335 * A handle to the input face.
338 * The pointer to the buffer that is allocated by
339 * @FT_ClassicKern_Validate.
342 * This function must be used to free the buffer allocated by
343 * @FT_ClassicKern_Validate only.
346 FT_ClassicKern_Free( FT_Face face
,
354 #endif /* __FTGXVAL_H__ */