OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ttpost.c */ | 3 /* ttpost.c */ |
4 /* */ | 4 /* */ |
5 /* Postcript name table processing for TrueType and OpenType fonts */ | 5 /* Postcript name table processing for TrueType and OpenType fonts */ |
6 /* (body). */ | 6 /* (body). */ |
7 /* */ | 7 /* */ |
8 /* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010 by */ | 8 /* Copyright 1996-2003, 2006-2010, 2013 by */ |
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
10 /* */ | 10 /* */ |
11 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 12 /* modified, and distributed under the terms of the FreeType project */ |
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
14 /* this file you indicate that you have read the license and */ | 14 /* this file you indicate that you have read the license and */ |
15 /* understand and accept it fully. */ | 15 /* understand and accept it fully. */ |
16 /* */ | 16 /* */ |
17 /***************************************************************************/ | 17 /***************************************************************************/ |
18 | 18 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 goto Exit; | 171 goto Exit; |
172 | 172 |
173 /* UNDOCUMENTED! The number of glyphs in this table can be smaller */ | 173 /* UNDOCUMENTED! The number of glyphs in this table can be smaller */ |
174 /* than the value in the maxp table (cf. cyberbit.ttf). */ | 174 /* than the value in the maxp table (cf. cyberbit.ttf). */ |
175 | 175 |
176 /* There already exist fonts which have more than 32768 glyph names */ | 176 /* There already exist fonts which have more than 32768 glyph names */ |
177 /* in this table, so the test for this threshold has been dropped. */ | 177 /* in this table, so the test for this threshold has been dropped. */ |
178 | 178 |
179 if ( num_glyphs > face->max_profile.numGlyphs ) | 179 if ( num_glyphs > face->max_profile.numGlyphs ) |
180 { | 180 { |
181 error = SFNT_Err_Invalid_File_Format; | 181 error = FT_THROW( Invalid_File_Format ); |
182 goto Exit; | 182 goto Exit; |
183 } | 183 } |
184 | 184 |
185 /* load the indices */ | 185 /* load the indices */ |
186 { | 186 { |
187 FT_Int n; | 187 FT_Int n; |
188 | 188 |
189 | 189 |
190 if ( FT_NEW_ARRAY ( glyph_indices, num_glyphs ) || | 190 if ( FT_NEW_ARRAY ( glyph_indices, num_glyphs ) || |
191 FT_FRAME_ENTER( num_glyphs * 2L ) ) | 191 FT_FRAME_ENTER( num_glyphs * 2L ) ) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 /* all right, set table fields and exit successfully */ | 277 /* all right, set table fields and exit successfully */ |
278 { | 278 { |
279 TT_Post_20 table = &face->postscript_names.names.format_20; | 279 TT_Post_20 table = &face->postscript_names.names.format_20; |
280 | 280 |
281 | 281 |
282 table->num_glyphs = (FT_UShort)num_glyphs; | 282 table->num_glyphs = (FT_UShort)num_glyphs; |
283 table->num_names = (FT_UShort)num_names; | 283 table->num_names = (FT_UShort)num_names; |
284 table->glyph_indices = glyph_indices; | 284 table->glyph_indices = glyph_indices; |
285 table->glyph_names = name_strings; | 285 table->glyph_names = name_strings; |
286 } | 286 } |
287 return SFNT_Err_Ok; | 287 return FT_Err_Ok; |
288 | 288 |
289 Fail1: | 289 Fail1: |
290 { | 290 { |
291 FT_UShort n; | 291 FT_UShort n; |
292 | 292 |
293 | 293 |
294 for ( n = 0; n < num_names; n++ ) | 294 for ( n = 0; n < num_names; n++ ) |
295 FT_FREE( name_strings[n] ); | 295 FT_FREE( name_strings[n] ); |
296 } | 296 } |
297 | 297 |
(...skipping 20 matching lines...) Expand all Loading... |
318 FT_UNUSED( post_limit ); | 318 FT_UNUSED( post_limit ); |
319 | 319 |
320 | 320 |
321 /* UNDOCUMENTED! This value appears only in the Apple TT specs. */ | 321 /* UNDOCUMENTED! This value appears only in the Apple TT specs. */ |
322 if ( FT_READ_USHORT( num_glyphs ) ) | 322 if ( FT_READ_USHORT( num_glyphs ) ) |
323 goto Exit; | 323 goto Exit; |
324 | 324 |
325 /* check the number of glyphs */ | 325 /* check the number of glyphs */ |
326 if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 ) | 326 if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 ) |
327 { | 327 { |
328 error = SFNT_Err_Invalid_File_Format; | 328 error = FT_THROW( Invalid_File_Format ); |
329 goto Exit; | 329 goto Exit; |
330 } | 330 } |
331 | 331 |
332 if ( FT_NEW_ARRAY( offset_table, num_glyphs ) || | 332 if ( FT_NEW_ARRAY( offset_table, num_glyphs ) || |
333 FT_STREAM_READ( offset_table, num_glyphs ) ) | 333 FT_STREAM_READ( offset_table, num_glyphs ) ) |
334 goto Fail; | 334 goto Fail; |
335 | 335 |
336 /* now check the offset table */ | 336 /* now check the offset table */ |
337 { | 337 { |
338 FT_Int n; | 338 FT_Int n; |
339 | 339 |
340 | 340 |
341 for ( n = 0; n < num_glyphs; n++ ) | 341 for ( n = 0; n < num_glyphs; n++ ) |
342 { | 342 { |
343 FT_Long idx = (FT_Long)n + offset_table[n]; | 343 FT_Long idx = (FT_Long)n + offset_table[n]; |
344 | 344 |
345 | 345 |
346 if ( idx < 0 || idx > num_glyphs ) | 346 if ( idx < 0 || idx > num_glyphs ) |
347 { | 347 { |
348 error = SFNT_Err_Invalid_File_Format; | 348 error = FT_THROW( Invalid_File_Format ); |
349 goto Fail; | 349 goto Fail; |
350 } | 350 } |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 /* OK, set table fields and exit successfully */ | 354 /* OK, set table fields and exit successfully */ |
355 { | 355 { |
356 TT_Post_25 table = &face->postscript_names.names.format_25; | 356 TT_Post_25 table = &face->postscript_names.names.format_25; |
357 | 357 |
358 | 358 |
359 table->num_glyphs = (FT_UShort)num_glyphs; | 359 table->num_glyphs = (FT_UShort)num_glyphs; |
360 table->offsets = offset_table; | 360 table->offsets = offset_table; |
361 } | 361 } |
362 | 362 |
363 return SFNT_Err_Ok; | 363 return FT_Err_Ok; |
364 | 364 |
365 Fail: | 365 Fail: |
366 FT_FREE( offset_table ); | 366 FT_FREE( offset_table ); |
367 | 367 |
368 Exit: | 368 Exit: |
369 return error; | 369 return error; |
370 } | 370 } |
371 | 371 |
372 | 372 |
373 static FT_Error | 373 static FT_Error |
(...skipping 21 matching lines...) Expand all Loading... |
395 /* go to beginning of subtable */ | 395 /* go to beginning of subtable */ |
396 if ( FT_STREAM_SKIP( 32 ) ) | 396 if ( FT_STREAM_SKIP( 32 ) ) |
397 goto Exit; | 397 goto Exit; |
398 | 398 |
399 /* now read postscript table */ | 399 /* now read postscript table */ |
400 if ( format == 0x00020000L ) | 400 if ( format == 0x00020000L ) |
401 error = load_format_20( face, stream, post_limit ); | 401 error = load_format_20( face, stream, post_limit ); |
402 else if ( format == 0x00028000L ) | 402 else if ( format == 0x00028000L ) |
403 error = load_format_25( face, stream, post_limit ); | 403 error = load_format_25( face, stream, post_limit ); |
404 else | 404 else |
405 error = SFNT_Err_Invalid_File_Format; | 405 error = FT_THROW( Invalid_File_Format ); |
406 | 406 |
407 face->postscript_names.loaded = 1; | 407 face->postscript_names.loaded = 1; |
408 | 408 |
409 Exit: | 409 Exit: |
410 return error; | 410 return error; |
411 } | 411 } |
412 | 412 |
413 | 413 |
414 FT_LOCAL_DEF( void ) | 414 FT_LOCAL_DEF( void ) |
415 tt_face_free_ps_names( TT_Face face ) | 415 tt_face_free_ps_names( TT_Face face ) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 FT_Error error; | 481 FT_Error error; |
482 TT_Post_Names names; | 482 TT_Post_Names names; |
483 FT_Fixed format; | 483 FT_Fixed format; |
484 | 484 |
485 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES | 485 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES |
486 FT_Service_PsCMaps psnames; | 486 FT_Service_PsCMaps psnames; |
487 #endif | 487 #endif |
488 | 488 |
489 | 489 |
490 if ( !face ) | 490 if ( !face ) |
491 return SFNT_Err_Invalid_Face_Handle; | 491 return FT_THROW( Invalid_Face_Handle ); |
492 | 492 |
493 if ( idx >= (FT_UInt)face->max_profile.numGlyphs ) | 493 if ( idx >= (FT_UInt)face->max_profile.numGlyphs ) |
494 return SFNT_Err_Invalid_Glyph_Index; | 494 return FT_THROW( Invalid_Glyph_Index ); |
495 | 495 |
496 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES | 496 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES |
497 psnames = (FT_Service_PsCMaps)face->psnames; | 497 psnames = (FT_Service_PsCMaps)face->psnames; |
498 if ( !psnames ) | 498 if ( !psnames ) |
499 return SFNT_Err_Unimplemented_Feature; | 499 return FT_THROW( Unimplemented_Feature ); |
500 #endif | 500 #endif |
501 | 501 |
502 names = &face->postscript_names; | 502 names = &face->postscript_names; |
503 | 503 |
504 /* `.notdef' by default */ | 504 /* `.notdef' by default */ |
505 *PSname = MAC_NAME( 0 ); | 505 *PSname = MAC_NAME( 0 ); |
506 | 506 |
507 format = face->postscript.FormatType; | 507 format = face->postscript.FormatType; |
508 | 508 |
509 if ( format == 0x00010000L ) | 509 if ( format == 0x00010000L ) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */ | 549 if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */ |
550 { | 550 { |
551 idx += table->offsets[idx]; | 551 idx += table->offsets[idx]; |
552 *PSname = MAC_NAME( idx ); | 552 *PSname = MAC_NAME( idx ); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 /* nothing to do for format == 0x00030000L */ | 556 /* nothing to do for format == 0x00030000L */ |
557 | 557 |
558 End: | 558 End: |
559 return SFNT_Err_Ok; | 559 return FT_Err_Ok; |
560 } | 560 } |
561 | 561 |
562 | 562 |
563 /* END */ | 563 /* END */ |
OLD | NEW |