| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* sfdriver.c */ | 3 /* sfdriver.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* High-level SFNT driver interface (body). */ | 5 /* High-level SFNT driver interface (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 1996-2007, 2009-2011 by */ | 7 /* Copyright 1996-2007, 2009-2013 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 #include "ttcmap.h" | 44 #include "ttcmap.h" |
| 45 #include "ttkern.h" | 45 #include "ttkern.h" |
| 46 #include "ttmtx.h" | 46 #include "ttmtx.h" |
| 47 | 47 |
| 48 #include FT_SERVICE_GLYPH_DICT_H | 48 #include FT_SERVICE_GLYPH_DICT_H |
| 49 #include FT_SERVICE_POSTSCRIPT_NAME_H | 49 #include FT_SERVICE_POSTSCRIPT_NAME_H |
| 50 #include FT_SERVICE_SFNT_H | 50 #include FT_SERVICE_SFNT_H |
| 51 #include FT_SERVICE_TT_CMAP_H | 51 #include FT_SERVICE_TT_CMAP_H |
| 52 | 52 |
| 53 |
| 53 /*************************************************************************/ | 54 /*************************************************************************/ |
| 54 /* */ | 55 /* */ |
| 55 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 56 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 56 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 57 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 57 /* messages during execution. */ | 58 /* messages during execution. */ |
| 58 /* */ | 59 /* */ |
| 59 #undef FT_COMPONENT | 60 #undef FT_COMPONENT |
| 60 #define FT_COMPONENT trace_sfdriver | 61 #define FT_COMPONENT trace_sfdriver |
| 61 | 62 |
| 62 | 63 |
| 63 /* | 64 /* |
| 64 * SFNT TABLE SERVICE | 65 * SFNT TABLE SERVICE |
| 65 * | 66 * |
| 66 */ | 67 */ |
| 67 | 68 |
| 68 static void* | 69 static void* |
| 69 get_sfnt_table( TT_Face face, | 70 get_sfnt_table( TT_Face face, |
| 70 FT_Sfnt_Tag tag ) | 71 FT_Sfnt_Tag tag ) |
| 71 { | 72 { |
| 72 void* table; | 73 void* table; |
| 73 | 74 |
| 74 | 75 |
| 75 switch ( tag ) | 76 switch ( tag ) |
| 76 { | 77 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 | 113 |
| 113 static FT_Error | 114 static FT_Error |
| 114 sfnt_table_info( TT_Face face, | 115 sfnt_table_info( TT_Face face, |
| 115 FT_UInt idx, | 116 FT_UInt idx, |
| 116 FT_ULong *tag, | 117 FT_ULong *tag, |
| 117 FT_ULong *offset, | 118 FT_ULong *offset, |
| 118 FT_ULong *length ) | 119 FT_ULong *length ) |
| 119 { | 120 { |
| 120 if ( !offset || !length ) | 121 if ( !offset || !length ) |
| 121 return SFNT_Err_Invalid_Argument; | 122 return FT_THROW( Invalid_Argument ); |
| 122 | 123 |
| 123 if ( !tag ) | 124 if ( !tag ) |
| 124 *length = face->num_tables; | 125 *length = face->num_tables; |
| 125 else | 126 else |
| 126 { | 127 { |
| 127 if ( idx >= face->num_tables ) | 128 if ( idx >= face->num_tables ) |
| 128 return SFNT_Err_Table_Missing; | 129 return FT_THROW( Table_Missing ); |
| 129 | 130 |
| 130 *tag = face->dir_tables[idx].Tag; | 131 *tag = face->dir_tables[idx].Tag; |
| 131 *offset = face->dir_tables[idx].Offset; | 132 *offset = face->dir_tables[idx].Offset; |
| 132 *length = face->dir_tables[idx].Length; | 133 *length = face->dir_tables[idx].Length; |
| 133 } | 134 } |
| 134 | 135 |
| 135 return SFNT_Err_Ok; | 136 return FT_Err_Ok; |
| 136 } | 137 } |
| 137 | 138 |
| 138 | 139 |
| 139 FT_DEFINE_SERVICE_SFNT_TABLEREC(sfnt_service_sfnt_table, | 140 FT_DEFINE_SERVICE_SFNT_TABLEREC( |
| 141 sfnt_service_sfnt_table, |
| 140 (FT_SFNT_TableLoadFunc)tt_face_load_any, | 142 (FT_SFNT_TableLoadFunc)tt_face_load_any, |
| 141 (FT_SFNT_TableGetFunc) get_sfnt_table, | 143 (FT_SFNT_TableGetFunc) get_sfnt_table, |
| 142 (FT_SFNT_TableInfoFunc)sfnt_table_info | 144 (FT_SFNT_TableInfoFunc)sfnt_table_info ) |
| 143 ) | |
| 144 | 145 |
| 145 | 146 |
| 146 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES | 147 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES |
| 147 | 148 |
| 148 /* | 149 /* |
| 149 * GLYPH DICT SERVICE | 150 * GLYPH DICT SERVICE |
| 150 * | 151 * |
| 151 */ | 152 */ |
| 152 | 153 |
| 153 static FT_Error | 154 static FT_Error |
| 154 sfnt_get_glyph_name( TT_Face face, | 155 sfnt_get_glyph_name( TT_Face face, |
| 155 FT_UInt glyph_index, | 156 FT_UInt glyph_index, |
| 156 FT_Pointer buffer, | 157 FT_Pointer buffer, |
| 157 FT_UInt buffer_max ) | 158 FT_UInt buffer_max ) |
| 158 { | 159 { |
| 159 FT_String* gname; | 160 FT_String* gname; |
| 160 FT_Error error; | 161 FT_Error error; |
| 161 | 162 |
| 162 | 163 |
| 163 error = tt_face_get_ps_name( face, glyph_index, &gname ); | 164 error = tt_face_get_ps_name( face, glyph_index, &gname ); |
| 164 if ( !error ) | 165 if ( !error ) |
| 165 FT_STRCPYN( buffer, gname, buffer_max ); | 166 FT_STRCPYN( buffer, gname, buffer_max ); |
| 166 | 167 |
| 167 return error; | 168 return error; |
| 168 } | 169 } |
| 169 | 170 |
| 170 | 171 |
| 171 static FT_UInt | 172 static FT_UInt |
| 172 sfnt_get_name_index( TT_Face face, | 173 sfnt_get_name_index( TT_Face face, |
| 173 FT_String* glyph_name ) | 174 FT_String* glyph_name ) |
| 174 { | 175 { |
| 175 FT_Face root = &face->root; | 176 FT_Face root = &face->root; |
| 176 FT_UInt i, max_gid = FT_UINT_MAX; | 177 |
| 178 FT_UInt i, max_gid = FT_UINT_MAX; |
| 177 | 179 |
| 178 | 180 |
| 179 if ( root->num_glyphs < 0 ) | 181 if ( root->num_glyphs < 0 ) |
| 180 return 0; | 182 return 0; |
| 181 else if ( ( FT_ULong ) root->num_glyphs < FT_UINT_MAX ) | 183 else if ( (FT_ULong)root->num_glyphs < FT_UINT_MAX ) |
| 182 max_gid = ( FT_UInt ) root->num_glyphs; | 184 max_gid = (FT_UInt)root->num_glyphs; |
| 183 else | 185 else |
| 184 FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n", | 186 FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n", |
| 185 FT_UINT_MAX, root->num_glyphs )); | 187 FT_UINT_MAX, root->num_glyphs )); |
| 186 | 188 |
| 187 for ( i = 0; i < max_gid; i++ ) | 189 for ( i = 0; i < max_gid; i++ ) |
| 188 { | 190 { |
| 189 FT_String* gname; | 191 FT_String* gname; |
| 190 FT_Error error = tt_face_get_ps_name( face, i, &gname ); | 192 FT_Error error = tt_face_get_ps_name( face, i, &gname ); |
| 191 | 193 |
| 192 | 194 |
| 193 if ( error ) | 195 if ( error ) |
| 194 continue; | 196 continue; |
| 195 | 197 |
| 196 if ( !ft_strcmp( glyph_name, gname ) ) | 198 if ( !ft_strcmp( glyph_name, gname ) ) |
| 197 return i; | 199 return i; |
| 198 } | 200 } |
| 199 | 201 |
| 200 return 0; | 202 return 0; |
| 201 } | 203 } |
| 202 | 204 |
| 203 | 205 |
| 204 FT_DEFINE_SERVICE_GLYPHDICTREC(sfnt_service_glyph_dict, | 206 FT_DEFINE_SERVICE_GLYPHDICTREC( |
| 207 sfnt_service_glyph_dict, |
| 205 (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, | 208 (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, |
| 206 (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index | 209 (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index ) |
| 207 ) | 210 |
| 208 | 211 |
| 209 #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ | 212 #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ |
| 210 | 213 |
| 211 | 214 |
| 212 /* | 215 /* |
| 213 * POSTSCRIPT NAME SERVICE | 216 * POSTSCRIPT NAME SERVICE |
| 214 * | 217 * |
| 215 */ | 218 */ |
| 216 | 219 |
| 217 static const char* | 220 static const char* |
| 218 sfnt_get_ps_name( TT_Face face ) | 221 sfnt_get_ps_name( TT_Face face ) |
| 219 { | 222 { |
| 220 FT_Int n, found_win, found_apple; | 223 FT_Int n, found_win, found_apple; |
| 221 const char* result = NULL; | 224 const char* result = NULL; |
| 222 | 225 |
| 223 | 226 |
| 224 /* shouldn't happen, but just in case to avoid memory leaks */ | 227 /* shouldn't happen, but just in case to avoid memory leaks */ |
| 225 if ( face->postscript_name ) | 228 if ( face->postscript_name ) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 247 name->languageID == 0 ) | 250 name->languageID == 0 ) |
| 248 found_apple = n; | 251 found_apple = n; |
| 249 } | 252 } |
| 250 } | 253 } |
| 251 | 254 |
| 252 if ( found_win != -1 ) | 255 if ( found_win != -1 ) |
| 253 { | 256 { |
| 254 FT_Memory memory = face->root.memory; | 257 FT_Memory memory = face->root.memory; |
| 255 TT_NameEntryRec* name = face->name_table.names + found_win; | 258 TT_NameEntryRec* name = face->name_table.names + found_win; |
| 256 FT_UInt len = name->stringLength / 2; | 259 FT_UInt len = name->stringLength / 2; |
| 257 FT_Error error = SFNT_Err_Ok; | 260 FT_Error error = FT_Err_Ok; |
| 258 | 261 |
| 259 FT_UNUSED( error ); | 262 FT_UNUSED( error ); |
| 260 | 263 |
| 261 | 264 |
| 262 if ( !FT_ALLOC( result, name->stringLength + 1 ) ) | 265 if ( !FT_ALLOC( result, name->stringLength + 1 ) ) |
| 263 { | 266 { |
| 264 FT_Stream stream = face->name_table.stream; | 267 FT_Stream stream = face->name_table.stream; |
| 265 FT_String* r = (FT_String*)result; | 268 FT_String* r = (FT_String*)result; |
| 266 FT_Byte* p = (FT_Byte*)name->string; | 269 FT_Byte* p = (FT_Byte*)name->string; |
| 267 | 270 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 289 FT_FRAME_EXIT(); | 292 FT_FRAME_EXIT(); |
| 290 } | 293 } |
| 291 goto Exit; | 294 goto Exit; |
| 292 } | 295 } |
| 293 | 296 |
| 294 if ( found_apple != -1 ) | 297 if ( found_apple != -1 ) |
| 295 { | 298 { |
| 296 FT_Memory memory = face->root.memory; | 299 FT_Memory memory = face->root.memory; |
| 297 TT_NameEntryRec* name = face->name_table.names + found_apple; | 300 TT_NameEntryRec* name = face->name_table.names + found_apple; |
| 298 FT_UInt len = name->stringLength; | 301 FT_UInt len = name->stringLength; |
| 299 FT_Error error = SFNT_Err_Ok; | 302 FT_Error error = FT_Err_Ok; |
| 300 | 303 |
| 301 FT_UNUSED( error ); | 304 FT_UNUSED( error ); |
| 302 | 305 |
| 303 | 306 |
| 304 if ( !FT_ALLOC( result, len + 1 ) ) | 307 if ( !FT_ALLOC( result, len + 1 ) ) |
| 305 { | 308 { |
| 306 FT_Stream stream = face->name_table.stream; | 309 FT_Stream stream = face->name_table.stream; |
| 307 | 310 |
| 308 | 311 |
| 309 if ( FT_STREAM_SEEK( name->stringOffset ) || | 312 if ( FT_STREAM_SEEK( name->stringOffset ) || |
| 310 FT_STREAM_READ( result, len ) ) | 313 FT_STREAM_READ( result, len ) ) |
| 311 { | 314 { |
| 312 name->stringOffset = 0; | 315 name->stringOffset = 0; |
| 313 name->stringLength = 0; | 316 name->stringLength = 0; |
| 314 FT_FREE( name->string ); | 317 FT_FREE( name->string ); |
| 315 FT_FREE( result ); | 318 FT_FREE( result ); |
| 316 goto Exit; | 319 goto Exit; |
| 317 } | 320 } |
| 318 ((char*)result)[len] = '\0'; | 321 ((char*)result)[len] = '\0'; |
| 319 } | 322 } |
| 320 } | 323 } |
| 321 | 324 |
| 322 Exit: | 325 Exit: |
| 323 face->postscript_name = result; | 326 face->postscript_name = result; |
| 324 return result; | 327 return result; |
| 325 } | 328 } |
| 326 | 329 |
| 327 FT_DEFINE_SERVICE_PSFONTNAMEREC(sfnt_service_ps_name, | 330 |
| 328 (FT_PsName_GetFunc)sfnt_get_ps_name | 331 FT_DEFINE_SERVICE_PSFONTNAMEREC( |
| 329 ) | 332 sfnt_service_ps_name, |
| 333 (FT_PsName_GetFunc)sfnt_get_ps_name ) |
| 330 | 334 |
| 331 | 335 |
| 332 /* | 336 /* |
| 333 * TT CMAP INFO | 337 * TT CMAP INFO |
| 334 */ | 338 */ |
| 335 FT_DEFINE_SERVICE_TTCMAPSREC(tt_service_get_cmap_info, | 339 FT_DEFINE_SERVICE_TTCMAPSREC( |
| 336 (TT_CMap_Info_GetFunc)tt_get_cmap_info | 340 tt_service_get_cmap_info, |
| 337 ) | 341 (TT_CMap_Info_GetFunc)tt_get_cmap_info ) |
| 338 | 342 |
| 339 | 343 |
| 340 #ifdef TT_CONFIG_OPTION_BDF | 344 #ifdef TT_CONFIG_OPTION_BDF |
| 341 | 345 |
| 342 static FT_Error | 346 static FT_Error |
| 343 sfnt_get_charset_id( TT_Face face, | 347 sfnt_get_charset_id( TT_Face face, |
| 344 const char* *acharset_encoding, | 348 const char* *acharset_encoding, |
| 345 const char* *acharset_registry ) | 349 const char* *acharset_registry ) |
| 346 { | 350 { |
| 347 BDF_PropertyRec encoding, registry; | 351 BDF_PropertyRec encoding, registry; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 360 error = tt_face_find_bdf_prop( face, "CHARSET_ENCODING", &encoding ); | 364 error = tt_face_find_bdf_prop( face, "CHARSET_ENCODING", &encoding ); |
| 361 if ( !error ) | 365 if ( !error ) |
| 362 { | 366 { |
| 363 if ( registry.type == BDF_PROPERTY_TYPE_ATOM && | 367 if ( registry.type == BDF_PROPERTY_TYPE_ATOM && |
| 364 encoding.type == BDF_PROPERTY_TYPE_ATOM ) | 368 encoding.type == BDF_PROPERTY_TYPE_ATOM ) |
| 365 { | 369 { |
| 366 *acharset_encoding = encoding.u.atom; | 370 *acharset_encoding = encoding.u.atom; |
| 367 *acharset_registry = registry.u.atom; | 371 *acharset_registry = registry.u.atom; |
| 368 } | 372 } |
| 369 else | 373 else |
| 370 error = SFNT_Err_Invalid_Argument; | 374 error = FT_THROW( Invalid_Argument ); |
| 371 } | 375 } |
| 372 } | 376 } |
| 373 | 377 |
| 374 return error; | 378 return error; |
| 375 } | 379 } |
| 376 | 380 |
| 377 | 381 |
| 378 FT_DEFINE_SERVICE_BDFRec(sfnt_service_bdf, | 382 FT_DEFINE_SERVICE_BDFRec( |
| 379 (FT_BDF_GetCharsetIdFunc) sfnt_get_charset_id, | 383 sfnt_service_bdf, |
| 380 (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop | 384 (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id, |
| 381 ) | 385 (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop ) |
| 386 |
| 382 | 387 |
| 383 #endif /* TT_CONFIG_OPTION_BDF */ | 388 #endif /* TT_CONFIG_OPTION_BDF */ |
| 384 | 389 |
| 385 | 390 |
| 386 /* | 391 /* |
| 387 * SERVICE LIST | 392 * SERVICE LIST |
| 388 */ | 393 */ |
| 389 | 394 |
| 390 #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF | 395 #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF |
| 391 FT_DEFINE_SERVICEDESCREC5(sfnt_services, | 396 FT_DEFINE_SERVICEDESCREC5( |
| 392 FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, | 397 sfnt_services, |
| 393 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, | 398 FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, |
| 394 FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET, | 399 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, |
| 395 FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET, | 400 FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, |
| 396 FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET | 401 FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, |
| 397 ) | 402 FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) |
| 398 #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES | 403 #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES |
| 399 FT_DEFINE_SERVICEDESCREC4(sfnt_services, | 404 FT_DEFINE_SERVICEDESCREC4( |
| 400 FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, | 405 sfnt_services, |
| 401 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, | 406 FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, |
| 402 FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET, | 407 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, |
| 403 FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET | 408 FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, |
| 404 ) | 409 FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) |
| 405 #elif defined TT_CONFIG_OPTION_BDF | 410 #elif defined TT_CONFIG_OPTION_BDF |
| 406 FT_DEFINE_SERVICEDESCREC4(sfnt_services, | 411 FT_DEFINE_SERVICEDESCREC4( |
| 407 FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, | 412 sfnt_services, |
| 408 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, | 413 FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, |
| 409 FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET, | 414 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, |
| 410 FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET | 415 FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, |
| 411 ) | 416 FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) |
| 412 #else | 417 #else |
| 413 FT_DEFINE_SERVICEDESCREC3(sfnt_services, | 418 FT_DEFINE_SERVICEDESCREC3( |
| 414 FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, | 419 sfnt_services, |
| 415 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, | 420 FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, |
| 416 FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET | 421 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, |
| 417 ) | 422 FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) |
| 418 #endif | 423 #endif |
| 419 | 424 |
| 420 | 425 |
| 421 FT_CALLBACK_DEF( FT_Module_Interface ) | 426 FT_CALLBACK_DEF( FT_Module_Interface ) |
| 422 sfnt_get_interface( FT_Module module, | 427 sfnt_get_interface( FT_Module module, |
| 423 const char* module_interface ) | 428 const char* module_interface ) |
| 424 { | 429 { |
| 425 /* FT_SFNT_SERVICES_GET derefers `library' in PIC mode */ | 430 /* SFNT_SERVICES_GET derefers `library' in PIC mode */ |
| 426 #ifdef FT_CONFIG_OPTION_PIC | 431 #ifdef FT_CONFIG_OPTION_PIC |
| 427 FT_Library library; | 432 FT_Library library; |
| 428 | 433 |
| 429 | 434 |
| 430 if ( !module ) | 435 if ( !module ) |
| 431 return NULL; | 436 return NULL; |
| 432 library = module->library; | 437 library = module->library; |
| 433 if ( !library ) | 438 if ( !library ) |
| 434 return NULL; | 439 return NULL; |
| 435 #else | 440 #else |
| 436 FT_UNUSED( module ); | 441 FT_UNUSED( module ); |
| 437 #endif | 442 #endif |
| 438 return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface ); | 443 |
| 444 return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface ); |
| 439 } | 445 } |
| 440 | 446 |
| 441 | 447 |
| 442 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
| 443 | |
| 444 FT_CALLBACK_DEF( FT_Error ) | |
| 445 tt_face_load_sfnt_header_stub( TT_Face face, | |
| 446 FT_Stream stream, | |
| 447 FT_Long face_index, | |
| 448 SFNT_Header header ) | |
| 449 { | |
| 450 FT_UNUSED( face ); | |
| 451 FT_UNUSED( stream ); | |
| 452 FT_UNUSED( face_index ); | |
| 453 FT_UNUSED( header ); | |
| 454 | |
| 455 return SFNT_Err_Unimplemented_Feature; | |
| 456 } | |
| 457 | |
| 458 | |
| 459 FT_CALLBACK_DEF( FT_Error ) | |
| 460 tt_face_load_directory_stub( TT_Face face, | |
| 461 FT_Stream stream, | |
| 462 SFNT_Header header ) | |
| 463 { | |
| 464 FT_UNUSED( face ); | |
| 465 FT_UNUSED( stream ); | |
| 466 FT_UNUSED( header ); | |
| 467 | |
| 468 return SFNT_Err_Unimplemented_Feature; | |
| 469 } | |
| 470 | |
| 471 | |
| 472 FT_CALLBACK_DEF( FT_Error ) | |
| 473 tt_face_load_hdmx_stub( TT_Face face, | |
| 474 FT_Stream stream ) | |
| 475 { | |
| 476 FT_UNUSED( face ); | |
| 477 FT_UNUSED( stream ); | |
| 478 | |
| 479 return SFNT_Err_Unimplemented_Feature; | |
| 480 } | |
| 481 | |
| 482 | |
| 483 FT_CALLBACK_DEF( void ) | |
| 484 tt_face_free_hdmx_stub( TT_Face face ) | |
| 485 { | |
| 486 FT_UNUSED( face ); | |
| 487 } | |
| 488 | |
| 489 | |
| 490 FT_CALLBACK_DEF( FT_Error ) | |
| 491 tt_face_set_sbit_strike_stub( TT_Face face, | |
| 492 FT_UInt x_ppem, | |
| 493 FT_UInt y_ppem, | |
| 494 FT_ULong* astrike_index ) | |
| 495 { | |
| 496 /* | |
| 497 * We simply forge a FT_Size_Request and call the real function | |
| 498 * that does all the work. | |
| 499 * | |
| 500 * This stub might be called by libXfont in the X.Org Xserver, | |
| 501 * compiled against version 2.1.8 or newer. | |
| 502 */ | |
| 503 | |
| 504 FT_Size_RequestRec req; | |
| 505 | |
| 506 | |
| 507 req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; | |
| 508 req.width = (FT_F26Dot6)x_ppem; | |
| 509 req.height = (FT_F26Dot6)y_ppem; | |
| 510 req.horiResolution = 0; | |
| 511 req.vertResolution = 0; | |
| 512 | |
| 513 *astrike_index = 0x7FFFFFFFUL; | |
| 514 | |
| 515 return tt_face_set_sbit_strike( face, &req, astrike_index ); | |
| 516 } | |
| 517 | |
| 518 | |
| 519 FT_CALLBACK_DEF( FT_Error ) | |
| 520 tt_face_load_sbit_stub( TT_Face face, | |
| 521 FT_Stream stream ) | |
| 522 { | |
| 523 FT_UNUSED( face ); | |
| 524 FT_UNUSED( stream ); | |
| 525 | |
| 526 /* | |
| 527 * This function was originally implemented to load the sbit table. | |
| 528 * However, it has been replaced by `tt_face_load_eblc', and this stub | |
| 529 * is only there for some rogue clients which would want to call it | |
| 530 * directly (which doesn't make much sense). | |
| 531 */ | |
| 532 return SFNT_Err_Unimplemented_Feature; | |
| 533 } | |
| 534 | |
| 535 | |
| 536 FT_CALLBACK_DEF( void ) | |
| 537 tt_face_free_sbit_stub( TT_Face face ) | |
| 538 { | |
| 539 /* nothing to do in this stub */ | |
| 540 FT_UNUSED( face ); | |
| 541 } | |
| 542 | |
| 543 | |
| 544 FT_CALLBACK_DEF( FT_Error ) | |
| 545 tt_face_load_charmap_stub( TT_Face face, | |
| 546 void* cmap, | |
| 547 FT_Stream input ) | |
| 548 { | |
| 549 FT_UNUSED( face ); | |
| 550 FT_UNUSED( cmap ); | |
| 551 FT_UNUSED( input ); | |
| 552 | |
| 553 return SFNT_Err_Unimplemented_Feature; | |
| 554 } | |
| 555 | |
| 556 | |
| 557 FT_CALLBACK_DEF( FT_Error ) | |
| 558 tt_face_free_charmap_stub( TT_Face face, | |
| 559 void* cmap ) | |
| 560 { | |
| 561 FT_UNUSED( face ); | |
| 562 FT_UNUSED( cmap ); | |
| 563 | |
| 564 return SFNT_Err_Ok; | |
| 565 } | |
| 566 | |
| 567 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 568 | |
| 569 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS | 448 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS |
| 570 #define PUT_EMBEDDED_BITMAPS(a) a | 449 #define PUT_EMBEDDED_BITMAPS( a ) a |
| 571 #else | 450 #else |
| 572 #define PUT_EMBEDDED_BITMAPS(a) 0 | 451 #define PUT_EMBEDDED_BITMAPS( a ) NULL |
| 573 #endif | |
| 574 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES | |
| 575 #define PUT_PS_NAMES(a) a | |
| 576 #else | |
| 577 #define PUT_PS_NAMES(a) 0 | |
| 578 #endif | 452 #endif |
| 579 | 453 |
| 580 FT_DEFINE_SFNT_INTERFACE(sfnt_interface, | 454 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES |
| 455 #define PUT_PS_NAMES( a ) a |
| 456 #else |
| 457 #define PUT_PS_NAMES( a ) NULL |
| 458 #endif |
| 459 |
| 460 FT_DEFINE_SFNT_INTERFACE( |
| 461 sfnt_interface, |
| 581 tt_face_goto_table, | 462 tt_face_goto_table, |
| 582 | 463 |
| 583 sfnt_init_face, | 464 sfnt_init_face, |
| 584 sfnt_load_face, | 465 sfnt_load_face, |
| 585 sfnt_done_face, | 466 sfnt_done_face, |
| 586 sfnt_get_interface, | 467 sfnt_get_interface, |
| 587 | 468 |
| 588 tt_face_load_any, | 469 tt_face_load_any, |
| 589 | 470 |
| 590 tt_face_load_sfnt_header_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 591 tt_face_load_directory_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 592 | |
| 593 tt_face_load_head, | 471 tt_face_load_head, |
| 594 tt_face_load_hhea, | 472 tt_face_load_hhea, |
| 595 tt_face_load_cmap, | 473 tt_face_load_cmap, |
| 596 tt_face_load_maxp, | 474 tt_face_load_maxp, |
| 597 tt_face_load_os2, | 475 tt_face_load_os2, |
| 598 tt_face_load_post, | 476 tt_face_load_post, |
| 599 | 477 |
| 600 tt_face_load_name, | 478 tt_face_load_name, |
| 601 tt_face_free_name, | 479 tt_face_free_name, |
| 602 | 480 |
| 603 tt_face_load_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 604 tt_face_free_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 605 | |
| 606 tt_face_load_kern, | 481 tt_face_load_kern, |
| 607 tt_face_load_gasp, | 482 tt_face_load_gasp, |
| 608 tt_face_load_pclt, | 483 tt_face_load_pclt, |
| 609 | 484 |
| 610 /* see `ttload.h' */ | 485 /* see `ttload.h' */ |
| 611 PUT_EMBEDDED_BITMAPS(tt_face_load_bhed), | 486 PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ), |
| 612 | 487 |
| 613 tt_face_set_sbit_strike_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | 488 PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ), |
| 614 tt_face_load_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 615 | |
| 616 tt_find_sbit_image, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 617 tt_load_sbit_metrics, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 618 | |
| 619 PUT_EMBEDDED_BITMAPS(tt_face_load_sbit_image), | |
| 620 | |
| 621 tt_face_free_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 622 | 489 |
| 623 /* see `ttpost.h' */ | 490 /* see `ttpost.h' */ |
| 624 PUT_PS_NAMES(tt_face_get_ps_name), | 491 PUT_PS_NAMES( tt_face_get_ps_name ), |
| 625 PUT_PS_NAMES(tt_face_free_ps_names), | 492 PUT_PS_NAMES( tt_face_free_ps_names ), |
| 626 | |
| 627 tt_face_load_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 628 tt_face_free_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 629 | 493 |
| 630 /* since version 2.1.8 */ | 494 /* since version 2.1.8 */ |
| 631 | |
| 632 tt_face_get_kerning, | 495 tt_face_get_kerning, |
| 633 | 496 |
| 634 /* since version 2.2 */ | 497 /* since version 2.2 */ |
| 635 | |
| 636 tt_face_load_font_dir, | 498 tt_face_load_font_dir, |
| 637 tt_face_load_hmtx, | 499 tt_face_load_hmtx, |
| 638 | 500 |
| 639 /* see `ttsbit.h' and `sfnt.h' */ | 501 /* see `ttsbit.h' and `sfnt.h' */ |
| 640 PUT_EMBEDDED_BITMAPS(tt_face_load_eblc), | 502 PUT_EMBEDDED_BITMAPS( tt_face_load_eblc ), |
| 641 PUT_EMBEDDED_BITMAPS(tt_face_free_eblc), | 503 PUT_EMBEDDED_BITMAPS( tt_face_free_eblc ), |
| 642 | 504 |
| 643 PUT_EMBEDDED_BITMAPS(tt_face_set_sbit_strike), | 505 PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), |
| 644 PUT_EMBEDDED_BITMAPS(tt_face_load_strike_metrics), | 506 PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), |
| 645 | 507 |
| 646 tt_face_get_metrics | 508 tt_face_get_metrics |
| 647 ) | 509 ) |
| 648 | 510 |
| 649 | 511 |
| 650 FT_DEFINE_MODULE(sfnt_module_class, | 512 FT_DEFINE_MODULE( |
| 513 sfnt_module_class, |
| 651 | 514 |
| 652 0, /* not a font driver or renderer */ | 515 0, /* not a font driver or renderer */ |
| 653 sizeof ( FT_ModuleRec ), | 516 sizeof ( FT_ModuleRec ), |
| 654 | 517 |
| 655 "sfnt", /* driver name */ | 518 "sfnt", /* driver name */ |
| 656 0x10000L, /* driver version 1.0 */ | 519 0x10000L, /* driver version 1.0 */ |
| 657 0x20000L, /* driver requires FreeType 2.0 or higher */ | 520 0x20000L, /* driver requires FreeType 2.0 or higher */ |
| 658 | 521 |
| 659 (const void*)&FT_SFNT_INTERFACE_GET, /* module specific interface */ | 522 (const void*)&SFNT_INTERFACE_GET, /* module specific interface */ |
| 660 | 523 |
| 661 (FT_Module_Constructor)0, | 524 (FT_Module_Constructor)0, |
| 662 (FT_Module_Destructor) 0, | 525 (FT_Module_Destructor) 0, |
| 663 (FT_Module_Requester) sfnt_get_interface | 526 (FT_Module_Requester) sfnt_get_interface ) |
| 664 ) | |
| 665 | 527 |
| 666 | 528 |
| 667 /* END */ | 529 /* END */ |
| OLD | NEW |