Hash :
8c90c22d
Author :
Date :
2002-06-08T06:47:18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
/***************************************************************************/
/* */
/* t42objs.c */
/* */
/* Type 42 objects manager (body). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "t42objs.h"
#include "t42parse.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_LIST_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
static FT_Error
T42_Open_Face( T42_Face face )
{
T42_LoaderRec loader;
T42_Parser parser;
T1_Font type1 = &face->type1;
FT_Memory memory = face->root.memory;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t42_loader_init( &loader, face );
parser = &loader.parser;
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
error = t42_parser_init( parser,
face->root.stream,
memory,
psaux);
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader, parser->base_dict, parser->base_len );
if ( type1->font_type != 42 )
{
error = T42_Err_Unknown_File_Format;
goto Exit;
}
/* now, propagate the charstrings and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init ) {
FT_ERROR(( "T42_Open_Face: no charstrings array in face!\n" ));
error = T42_Err_Invalid_File_Format;
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* char_name;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* as defined in the CharStrings array. */
/* The index is then stored in type1.encoding.char_index, and */
/* the name in type1.encoding.char_name */
min_char = +32000;
max_char = -32000;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char ) min_char = charcode;
if ( charcode > max_char ) max_char = charcode;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t42_loader_done( &loader );
return error;
}
/***************** Driver Functions *************/
FT_LOCAL_DEF( FT_Error )
T42_Face_Init( FT_Stream stream,
T42_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params)
{
FT_Error error;
PSNames_Service psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( face_index );
FT_UNUSED( stream );
face->ttf_face = NULL;
face->root.num_faces = 1;
face->psnames = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psnames" );
psnames = (PSNames_Service)face->psnames;
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
if ( error )
goto Exit;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( face_index != 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
error = T42_Err_Invalid_Argument;
goto Exit;
}
/* Now, load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
root->num_glyphs = face->type1.num_glyphs;
root->num_charmaps = 0;
root->face_index = face_index;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
if ( face->type1.font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = face->type1.font_info.family_name;
if ( root->family_name )
{
char* full = face->type1.font_info.full_name;
char* family = root->family_name;
if ( full )
{
while ( *family && *full == *family )
{
family++;
full++;
}
root->style_name = ( *full == ' ' ? full + 1
: (char *)"Regular" );
}
else
root->style_name = (char *)"Regular";
}
else
{
/* do we have a `/FontName'? */
if ( face->type1.font_name )
{
root->family_name = face->type1.font_name;
root->style_name = (char *)"Regular";
}
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = 0;
/* Load the TTF font embedded in the T42 font */
error = FT_New_Memory_Face( FT_FACE_LIBRARY( face ),
face->ttf_data,
face->ttf_size,
0,
&face->ttf_face );
if ( error )
goto Exit;
/* Ignore info in FontInfo dictionary and use the info from the */
/* loaded TTF font. The PostScript interpreter also ignores it. */
root->bbox = face->ttf_face->bbox;
root->units_per_EM = face->ttf_face->units_per_EM;
root->ascender = face->ttf_face->ascender;
root->descender = face->ttf_face->descender;
root->height = face->ttf_face->height;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_height = face->ttf_face->max_advance_height;
root->underline_position = face->type1.font_info.underline_position;
root->underline_thickness = face->type1.font_info.underline_thickness;
root->internal->max_points = 0;
root->internal->max_contours = 0;
/* compute style flags */
root->style_flags = 0;
if ( face->type1.font_info.italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
root->style_flags |= FT_STYLE_FLAG_BOLD;
if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
if ( psnames && psaux )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
FT_CMap_Class clazz;
charmap.face = root;
/* first of all, try to synthetize a Unicode charmap */
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.encoding = ft_encoding_unicode;
FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
/* now, generate an Adobe Standard encoding when appropriate */
charmap.platform_id = 7;
clazz = NULL;
switch ( face->type1.encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = ft_encoding_adobe_standard;
charmap.encoding_id = 0;
clazz = cmap_classes->standard;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap.encoding = ft_encoding_adobe_expert;
charmap.encoding_id = 1;
clazz = cmap_classes->expert;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap.encoding = ft_encoding_adobe_custom;
charmap.encoding_id = 2;
clazz = cmap_classes->custom;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap.encoding = ft_encoding_latin_1;
charmap.encoding_id = 3;
clazz = cmap_classes->unicode;
break;
default:
;
}
if ( clazz )
FT_CMap_New( clazz, NULL, &charmap, NULL );
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
}
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
/* charmap support -- synthetize unicode charmap if possible */
{
FT_CharMap charmap = face->charmaprecs;
/* synthesize a Unicode charmap if there is support in the `PSNames' */
/* module */
if ( psnames && psnames->unicode_value )
{
error = psnames->build_unicodes( root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
charmap->encoding = ft_encoding_unicode;
charmap->platform_id = 3;
charmap->encoding_id = 1;
charmap++;
}
/* XXX: Is the following code correct? It is used in t1objs.c */
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
error = T42_Err_Ok;
}
/* now, support either the standard, expert, or custom encoding */
charmap->face = (FT_Face)face;
charmap->platform_id = 7; /* a new platform id for Adobe fonts? */
switch ( face->type1.encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap->encoding = ft_encoding_latin_1;
charmap->encoding_id = 3;
break;
default:
FT_ERROR(( "T42_Face_Init: invalid encoding\n" ));
error = T42_Err_Invalid_File_Format;
goto Exit;
}
root->charmaps = face->charmaps;
root->num_charmaps = charmap - face->charmaprecs + 1;
face->charmaps[0] = &face->charmaprecs[0];
face->charmaps[1] = &face->charmaprecs[1];
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
Exit:
return error;
}
FT_LOCAL_DEF( void )
T42_Face_Done( T42_Face face )
{
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
if ( face )
{
type1 = &face->type1;
info = &type1->font_info;
memory = face->root.memory;
/* delete internal ttf face prior to freeing face->ttf_data */
if ( face->ttf_face )
FT_Done_Face( face->ttf_face );
/* release font info strings */
FT_FREE( info->version );
FT_FREE( info->notice );
FT_FREE( info->full_name );
FT_FREE( info->family_name );
FT_FREE( info->weight );
/* release top dictionary */
FT_FREE( type1->charstrings_len );
FT_FREE( type1->charstrings );
FT_FREE( type1->glyph_names );
FT_FREE( type1->charstrings_block );
FT_FREE( type1->glyph_names_block );
FT_FREE( type1->encoding.char_index );
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( face->ttf_data );
#if 0
/* release afm data if present */
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FT_FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = 0;
face->root.style_name = 0;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* T42_Driver_Init */
/* */
/* <Description> */
/* Initializes a given Type 42 driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
T42_Driver_Init( T42_Driver driver )
{
FT_Module ttmodule;
ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return T42_Err_Ok;
}
FT_LOCAL_DEF( void )
T42_Driver_Done( T42_Driver driver )
{
FT_UNUSED( driver );
}
FT_LOCAL_DEF( FT_UInt )
T42_CMap_CharIndex( FT_CharMap charmap,
FT_Long charcode )
{
T42_Face face;
FT_UInt result = 0;
PSNames_Service psnames;
face = (T42_Face)charmap->face;
psnames = (PSNames_Service)face->psnames;
if (!psnames )
goto Exit;
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* if this charmap is used, we ignore the encoding of the font and */
/* use the `PSNames' module to synthetize the Unicode charmap */
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
/* the function returns 0xFFFF if the Unicode charcode has */
/* no corresponding glyph */
if ( result == 0xFFFFU )
result = 0;
/* The result returned is the index (position)in the CharStrings */
/* array. This must be used now to get the value associated to */
/* that glyph_name, which is the real index within the truetype */
/* structure. */
result = ft_atoi( (const char*)face->type1.charstrings[result] );
goto Exit;
/*******************************************************************/
/* */
/* ISOLatin1 encoding support */
/* */
case ft_encoding_latin_1:
/* ISOLatin1 is the first page of Unicode */
if ( charcode < 256 && psnames->unicode_value )
{
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
/* the function returns 0xFFFF if the Unicode charcode has */
/* no corresponding glyph */
if ( result == 0xFFFFU )
result = 0;
}
goto Exit;
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding encoding = &face->type1.encoding;
if ( charcode >= encoding->code_first &&
charcode <= encoding->code_last )
{
FT_UInt idx = encoding->char_index[charcode];
result = ft_atoi( (const char *)face->type1.charstrings[idx] );
}
goto Exit;
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
if ( charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
break;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && ( ft_strcmp( gname, glyph_name ) == 0 ) )
{
result = ft_atoi( (const char *)face->type1.charstrings[n] );
break;
}
}
}
}
Exit:
return result;
}
FT_LOCAL_DEF( FT_Error )
T42_Size_Init( T42_Size size )
{
FT_Face face = size->root.face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error = T42_Err_Ok;
error = FT_New_Size( t42face->ttf_face, &ttsize );
size->ttsize = ttsize;
return error;
}
FT_LOCAL_DEF( void )
T42_Size_Done( T42_Size size )
{
FT_Face face = size->root.face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
if ( node )
{
FT_Done_Size( size->ttsize );
size->ttsize = NULL;
}
}
FT_LOCAL_DEF( FT_Error )
T42_GlyphSlot_Init( T42_GlyphSlot slot )
{
FT_Face face = slot->root.face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot ttslot;
FT_Error error = T42_Err_Ok;
if ( face->glyph == NULL )
{
/* First glyph slot for this face */
slot->ttslot = t42face->ttf_face->glyph;
}
else
{
error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
slot->ttslot = ttslot;
}
return error;
}
FT_LOCAL_DEF( void )
T42_GlyphSlot_Done( T42_GlyphSlot slot )
{
FT_Face face = slot->root.face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot cur = t42face->ttf_face->glyph;
while ( cur )
{
if ( cur == slot->ttslot )
{
FT_Done_GlyphSlot( slot->ttslot );
break;
}
cur = cur->next;
}
}
FT_LOCAL_DEF( FT_Error )
T42_Size_SetChars( T42_Size size,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
FT_Face face = size->root.face;
T42_Face t42face = (T42_Face)face;
return FT_Set_Char_Size( t42face->ttf_face,
char_width,
char_height,
horz_resolution,
vert_resolution );
}
FT_LOCAL_DEF( FT_Error )
T42_Size_SetPixels( T42_Size size,
FT_UInt pixel_width,
FT_UInt pixel_height )
{
FT_Face face = size->root.face;
T42_Face t42face = (T42_Face)face;
return FT_Set_Pixel_Sizes( t42face->ttf_face,
pixel_width,
pixel_height );
}
static void
ft_glyphslot_clear( FT_GlyphSlot slot )
{
/* free bitmap if needed */
if ( slot->flags & FT_GLYPH_OWN_BITMAP )
{
FT_Memory memory = FT_FACE_MEMORY( slot->face );
FT_FREE( slot->bitmap.buffer );
slot->flags &= ~FT_GLYPH_OWN_BITMAP;
}
/* clear all public fields in the glyph slot */
FT_MEM_SET( &slot->metrics, 0, sizeof ( slot->metrics ) );
FT_MEM_SET( &slot->outline, 0, sizeof ( slot->outline ) );
FT_MEM_SET( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
slot->bitmap_left = 0;
slot->bitmap_top = 0;
slot->num_subglyphs = 0;
slot->subglyphs = 0;
slot->control_data = 0;
slot->control_len = 0;
slot->other = 0;
slot->format = ft_glyph_format_none;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
}
FT_LOCAL_DEF( FT_Error )
T42_GlyphSlot_Load( FT_GlyphSlot glyph,
FT_Size size,
FT_Int glyph_index,
FT_Int load_flags )
{
FT_Error error;
T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph;
T42_Size t42size = (T42_Size)size;
FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
ft_glyphslot_clear( t42slot->ttslot );
error = ttclazz->load_glyph( t42slot->ttslot,
t42size->ttsize,
glyph_index,
load_flags | FT_LOAD_NO_BITMAP );
if ( !error )
{
glyph->metrics = t42slot->ttslot->metrics;
glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;
glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;
glyph->format = t42slot->ttslot->format;
glyph->outline = t42slot->ttslot->outline;
glyph->bitmap = t42slot->ttslot->bitmap;
glyph->bitmap_left = t42slot->ttslot->bitmap_left;
glyph->bitmap_top = t42slot->ttslot->bitmap_top;
}
return error;
}
FT_LOCAL_DEF( FT_Long )
T42_CMap_CharNext( FT_CharMap charmap,
FT_Long charcode )
{
T42_Face face;
PSNames_Service psnames;
face = (T42_Face)charmap->face;
psnames = (PSNames_Service)face->psnames;
if ( psnames )
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* use the `PSNames' module to synthetize the Unicode charmap */
return psnames->next_unicode( &face->unicode_map,
(FT_ULong)charcode );
/*******************************************************************/
/* */
/* ISOLatin1 encoding support */
/* */
case ft_encoding_latin_1:
{
FT_ULong code;
/* use the `PSNames' module to synthetize the Unicode charmap */
code = psnames->next_unicode( &face->unicode_map,
(FT_ULong)charcode );
if ( code < 256 )
return code;
break;
}
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding encoding = &face->type1.encoding;
charcode++;
if ( charcode < encoding->code_first )
charcode = encoding->code_first;
while ( charcode <= encoding->code_last ) {
if ( encoding->char_index[charcode] )
return charcode;
charcode++;
}
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
while ( ++charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
continue;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
ft_strcmp( gname, glyph_name ) == 0 )
return charcode;
}
}
}
return 0;
}
/* END */