00001 /***************************************************************************/ 00002 /* */ 00003 /* ftgxval.h */ 00004 /* */ 00005 /* FreeType API for validating TrueTypeGX/AAT tables (specification). */ 00006 /* */ 00007 /* Copyright 2004, 2005, 2006 by */ 00008 /* Masatake YAMATO, Redhat K.K, */ 00009 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00010 /* */ 00011 /* This file is part of the FreeType project, and may only be used, */ 00012 /* modified, and distributed under the terms of the FreeType project */ 00013 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00014 /* this file you indicate that you have read the license and */ 00015 /* understand and accept it fully. */ 00016 /* */ 00017 /***************************************************************************/ 00018 00019 /***************************************************************************/ 00020 /* */ 00021 /* gxvalid is derived from both gxlayout module and otvalid module. */ 00022 /* Development of gxlayout is supported by the Information-technology */ 00023 /* Promotion Agency(IPA), Japan. */ 00024 /* */ 00025 /***************************************************************************/ 00026 00027 00028 #ifndef __FTGXVAL_H__ 00029 #define __FTGXVAL_H__ 00030 00031 #include <ft2build.h> 00032 #include FT_FREETYPE_H 00033 00034 #ifdef FREETYPE_H 00035 #error "freetype.h of FreeType 1 has been loaded!" 00036 #error "Please fix the directory search order for header files" 00037 #error "so that freetype.h of FreeType 2 is found first." 00038 #endif 00039 00040 00041 FT_BEGIN_HEADER 00042 00043 00044 /*************************************************************************/ 00045 /* */ 00046 /* <Section> */ 00047 /* gx_validation */ 00048 /* */ 00049 /* <Title> */ 00050 /* TrueTypeGX/AAT Validation */ 00051 /* */ 00052 /* <Abstract> */ 00053 /* An API to validate TrueTypeGX/AAT tables. */ 00054 /* */ 00055 /* <Description> */ 00056 /* This section contains the declaration of functions to validate */ 00057 /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ 00058 /* trak, prop, lcar). */ 00059 /* */ 00060 /*************************************************************************/ 00061 00062 00063 /*************************************************************************/ 00064 /* */ 00065 /* */ 00066 /* Warning: Use FT_VALIDATE_XXX to validate a table. */ 00067 /* Following definitions are for gxvalid developers. */ 00068 /* */ 00069 /* */ 00070 /*************************************************************************/ 00071 00072 #define FT_VALIDATE_feat_INDEX 0 00073 #define FT_VALIDATE_mort_INDEX 1 00074 #define FT_VALIDATE_morx_INDEX 2 00075 #define FT_VALIDATE_bsln_INDEX 3 00076 #define FT_VALIDATE_just_INDEX 4 00077 #define FT_VALIDATE_kern_INDEX 5 00078 #define FT_VALIDATE_opbd_INDEX 6 00079 #define FT_VALIDATE_trak_INDEX 7 00080 #define FT_VALIDATE_prop_INDEX 8 00081 #define FT_VALIDATE_lcar_INDEX 9 00082 #define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX 00083 00084 00085 /************************************************************************* 00086 * 00087 * @macro: 00088 * FT_VALIDATE_GX_LENGTH 00089 * 00090 * @description: 00091 * The number of tables checked in this module. Use it as a parameter 00092 * for the `table-length' argument of function @FT_TrueTypeGX_Validate. 00093 */ 00094 #define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1) 00095 00096 /* */ 00097 00098 /* Up to 0x1000 is used by otvalid. 00099 Ox2xxx is reserved for feature OT extension. */ 00100 #define FT_VALIDATE_GX_START 0x4000 00101 #define FT_VALIDATE_GX_BITFIELD( tag ) \ 00102 ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) 00103 00104 00105 /********************************************************************** 00106 * 00107 * @enum: 00108 * FT_VALIDATE_GXXXX 00109 * 00110 * @description: 00111 * A list of bit-field constants used with @FT_TrueTypeGX_Validate to 00112 * indicate which TrueTypeGX/AAT Type tables should be validated. 00113 * 00114 * @values: 00115 * FT_VALIDATE_feat :: 00116 * Validate `feat' table. 00117 * 00118 * FT_VALIDATE_mort :: 00119 * Validate `mort' table. 00120 * 00121 * FT_VALIDATE_morx :: 00122 * Validate `morx' table. 00123 * 00124 * FT_VALIDATE_bsln :: 00125 * Validate `bsln' table. 00126 * 00127 * FT_VALIDATE_just :: 00128 * Validate `just' table. 00129 * 00130 * FT_VALIDATE_kern :: 00131 * Validate `kern' table. 00132 * 00133 * FT_VALIDATE_opbd :: 00134 * Validate `opbd' table. 00135 * 00136 * FT_VALIDATE_trak :: 00137 * Validate `trak' table. 00138 * 00139 * FT_VALIDATE_prop :: 00140 * Validate `prop' table. 00141 * 00142 * FT_VALIDATE_lcar :: 00143 * Validate `lcar' table. 00144 * 00145 * FT_VALIDATE_GX :: 00146 * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, 00147 * opbd, trak, prop and lcar). 00148 * 00149 */ 00150 00151 #define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) 00152 #define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) 00153 #define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) 00154 #define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) 00155 #define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) 00156 #define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) 00157 #define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) 00158 #define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) 00159 #define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) 00160 #define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) 00161 00162 #define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ 00163 FT_VALIDATE_mort | \ 00164 FT_VALIDATE_morx | \ 00165 FT_VALIDATE_bsln | \ 00166 FT_VALIDATE_just | \ 00167 FT_VALIDATE_kern | \ 00168 FT_VALIDATE_opbd | \ 00169 FT_VALIDATE_trak | \ 00170 FT_VALIDATE_prop | \ 00171 FT_VALIDATE_lcar ) 00172 00173 00174 /* */ 00175 00176 /********************************************************************** 00177 * 00178 * @function: 00179 * FT_TrueTypeGX_Validate 00180 * 00181 * @description: 00182 * Validate various TrueTypeGX tables to assure that all offsets and 00183 * indices are valid. The idea is that a higher-level library which 00184 * actually does the text layout can access those tables without 00185 * error checking (which can be quite time consuming). 00186 * 00187 * @input: 00188 * face :: 00189 * A handle to the input face. 00190 * 00191 * validation_flags :: 00192 * A bit field which specifies the tables to be validated. See 00193 * @FT_VALIDATE_GXXXX for possible values. 00194 * 00195 * table_length :: 00196 * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH 00197 * should be passed. 00198 * 00199 * @output: 00200 * tables :: 00201 * The array where all validated sfnt tables are stored. 00202 * The array itself must be allocated by a client. 00203 * 00204 * @return: 00205 * FreeType error code. 0~means success. 00206 * 00207 * @note: 00208 * This function only works with TrueTypeGX fonts, returning an error 00209 * otherwise. 00210 * 00211 * After use, the application should deallocate the buffers pointed to by 00212 * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value 00213 * indicates that the table either doesn't exist in the font, the 00214 * application hasn't asked for validation, or the validator doesn't have 00215 * the ability to validate the sfnt table. 00216 */ 00217 FT_EXPORT( FT_Error ) 00218 FT_TrueTypeGX_Validate( FT_Face face, 00219 FT_UInt validation_flags, 00220 FT_Bytes tables[FT_VALIDATE_GX_LENGTH], 00221 FT_UInt table_length ); 00222 00223 00224 /* */ 00225 00226 /********************************************************************** 00227 * 00228 * @function: 00229 * FT_TrueTypeGX_Free 00230 * 00231 * @description: 00232 * Free the buffer allocated by TrueTypeGX validator. 00233 * 00234 * @input: 00235 * face :: 00236 * A handle to the input face. 00237 * 00238 * table :: 00239 * The pointer to the buffer allocated by 00240 * @FT_TrueTypeGX_Validate. 00241 * 00242 * @note: 00243 * This function must be used to free the buffer allocated by 00244 * @FT_TrueTypeGX_Validate only. 00245 */ 00246 FT_EXPORT( void ) 00247 FT_TrueTypeGX_Free( FT_Face face, 00248 FT_Bytes table ); 00249 00250 00251 /* */ 00252 00253 /********************************************************************** 00254 * 00255 * @enum: 00256 * FT_VALIDATE_CKERNXXX 00257 * 00258 * @description: 00259 * A list of bit-field constants used with @FT_ClassicKern_Validate 00260 * to indicate the classic kern dialect or dialects. If the selected 00261 * type doesn't fit, @FT_ClassicKern_Validate regards the table as 00262 * invalid. 00263 * 00264 * @values: 00265 * FT_VALIDATE_MS :: 00266 * Handle the `kern' table as a classic Microsoft kern table. 00267 * 00268 * FT_VALIDATE_APPLE :: 00269 * Handle the `kern' table as a classic Apple kern table. 00270 * 00271 * FT_VALIDATE_CKERN :: 00272 * Handle the `kern' as either classic Apple or Microsoft kern table. 00273 */ 00274 #define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) 00275 #define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) 00276 00277 #define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) 00278 00279 00280 /* */ 00281 00282 /********************************************************************** 00283 * 00284 * @function: 00285 * FT_ClassicKern_Validate 00286 * 00287 * @description: 00288 * Validate classic (16-bit format) kern table to assure that the offsets 00289 * and indices are valid. The idea is that a higher-level library which 00290 * actually does the text layout can access those tables without error 00291 * checking (which can be quite time consuming). 00292 * 00293 * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both 00294 * the new 32-bit format and the classic 16-bit format, while 00295 * FT_ClassicKern_Validate only supports the classic 16-bit format. 00296 * 00297 * @input: 00298 * face :: 00299 * A handle to the input face. 00300 * 00301 * validation_flags :: 00302 * A bit field which specifies the dialect to be validated. See 00303 * @FT_VALIDATE_CKERNXXX for possible values. 00304 * 00305 * @output: 00306 * ckern_table :: 00307 * A pointer to the kern table. 00308 * 00309 * @return: 00310 * FreeType error code. 0~means success. 00311 * 00312 * @note: 00313 * After use, the application should deallocate the buffers pointed to by 00314 * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value 00315 * indicates that the table doesn't exist in the font. 00316 */ 00317 FT_EXPORT( FT_Error ) 00318 FT_ClassicKern_Validate( FT_Face face, 00319 FT_UInt validation_flags, 00320 FT_Bytes *ckern_table ); 00321 00322 00323 /* */ 00324 00325 /********************************************************************** 00326 * 00327 * @function: 00328 * FT_ClassicKern_Free 00329 * 00330 * @description: 00331 * Free the buffer allocated by classic Kern validator. 00332 * 00333 * @input: 00334 * face :: 00335 * A handle to the input face. 00336 * 00337 * table :: 00338 * The pointer to the buffer that is allocated by 00339 * @FT_ClassicKern_Validate. 00340 * 00341 * @note: 00342 * This function must be used to free the buffer allocated by 00343 * @FT_ClassicKern_Validate only. 00344 */ 00345 FT_EXPORT( void ) 00346 FT_ClassicKern_Free( FT_Face face, 00347 FT_Bytes table ); 00348 00349 00350 /* */ 00351 00352 00353 FT_END_HEADER 00354 00355 #endif /* __FTGXVAL_H__ */ 00356 00357 00358 /* END */