static FT_Int t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder, FT_Int charcode ) { FT_UInt n; const FT_String* glyph_name; FT_Service_PsCMaps psnames = decoder->psnames; /* check range of standard char code */ if ( charcode < 0 || charcode > 255 ) return -1; glyph_name = psnames->adobe_std_strings( psnames->adobe_std_encoding[charcode]); for ( n = 0; n < decoder->num_glyphs; n++ ) { FT_String* name = (FT_String*)decoder->glyph_names[n]; if ( name && name[0] == glyph_name[0] && ft_strcmp( name, glyph_name ) == 0 ) return n; } return -1; }
t1_cmap_unicode_char_next( PS_Unicodes unicodes, FT_UInt32 *pchar_code ) { T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; return psnames->unicodes_char_next( unicodes, pchar_code ); }
cff_cmap_unicode_char_next( PS_Unicodes unicodes, FT_UInt32 *pchar_code ) { TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); CFF_Font cff = (CFF_Font)face->extra.data; FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; return psnames->unicodes_char_next( unicodes, pchar_code ); }
t1_cmap_unicode_init( PS_Unicodes unicodes, FT_Pointer init_data ) /* XXX EMSCRIPTEN */ { T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; FT_UNUSED(init_data); /* XXX EMSCRIPTEN */ return psnames->unicodes_init( memory, unicodes, face->type1.num_glyphs, (PS_GetGlyphNameFunc)&t1_get_glyph_name, (PS_FreeGlyphNameFunc)NULL, (FT_Pointer)face ); }
t1_cmap_unicode_init( PS_Unicodes unicodes ) { T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; return psnames->unicodes_init( memory, unicodes, face->type1.num_glyphs, (PS_GetGlyphNameFunc)&psaux_get_glyph_name, (PS_FreeGlyphNameFunc)NULL, (FT_Pointer)face ); }
static FT_UInt cff_get_name_index( CFF_Face face, FT_String* glyph_name ) { CFF_Font cff; CFF_Charset charset; FT_Service_PsCMaps psnames; FT_Memory memory = FT_FACE_MEMORY( face ); FT_String* name; FT_UShort sid; FT_UInt i; FT_Int result; cff = (CFF_FontRec *)face->extra.data; charset = &cff->charset; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); if ( !psnames ) return 0; for ( i = 0; i < cff->num_glyphs; i++ ) { sid = charset->sids[i]; if ( sid > 390 ) name = cff_index_get_name( &cff->string_index, sid - 391 ); else name = (FT_String *)psnames->adobe_std_strings( sid ); if ( !name ) continue; result = ft_strcmp( glyph_name, name ); if ( sid > 390 ) FT_FREE( name ); if ( !result ) return i; } return 0; }
cff_cmap_unicode_init( PS_Unicodes unicodes ) { TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); CFF_Font cff = (CFF_Font)face->extra.data; CFF_Charset charset = &cff->charset; FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; /* can't build Unicode map for CID-keyed font */ if ( !charset->sids ) return CFF_Err_Invalid_Argument; return psnames->unicodes_init( memory, unicodes, cff->num_glyphs, (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name, (PS_FreeGlyphNameFunc)&cff_sid_free_glyph_name, (FT_Pointer)face ); }
cff_cmap_unicode_init( PS_Unicodes unicodes ) { TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); CFF_Font cff = (CFF_Font)face->extra.data; CFF_Charset charset = &cff->charset; FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; /* can't build Unicode map for CID-keyed font */ /* because we don't know glyph names. */ if ( !charset->sids ) return FT_THROW( No_Unicode_Glyph_Name ); return psnames->unicodes_init( memory, unicodes, cff->num_glyphs, (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name, (PS_FreeGlyphNameFunc)NULL, (FT_Pointer)face ); }
cff_index_get_sid_string( CFF_Index idx, FT_UInt sid, FT_Service_PsCMaps psnames ) { /* value 0xFFFFU indicates a missing dictionary entry */ if ( sid == 0xFFFFU ) return 0; /* if it is not a standard string, return it */ if ( sid > 390 ) return cff_index_get_name( idx, sid - 391 ); /* CID-keyed CFF fonts don't have glyph names */ if ( !psnames ) return 0; /* that's a standard string, fetch a copy from the PSName module */ { FT_String* name = 0; const char* adobe_name = psnames->adobe_std_strings( sid ); FT_UInt len; if ( adobe_name ) { FT_Memory memory = idx->stream->memory; FT_Error error; len = (FT_UInt)ft_strlen( adobe_name ); if ( !FT_ALLOC( name, len + 1 ) ) { FT_MEM_COPY( name, adobe_name, len ); name[len] = 0; } FT_UNUSED( error ); } return name; } }
static FT_UInt cff_get_name_index( CFF_Face face, FT_String* glyph_name ) { CFF_Font cff; CFF_Charset charset; FT_Service_PsCMaps psnames; FT_String* name; FT_UShort sid; FT_UInt i; cff = (CFF_FontRec *)face->extra.data; charset = &cff->charset; /* CFF2 table does not have glyph names; */ /* we need to use `post' table method */ if ( cff->version_major == 2 ) { FT_Library library = FT_FACE_LIBRARY( face ); FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); FT_Service_GlyphDict service = (FT_Service_GlyphDict)ft_module_get_service( sfnt_module, FT_SERVICE_ID_GLYPH_DICT, 0 ); if ( service && service->name_index ) return service->name_index( FT_FACE( face ), glyph_name ); else { FT_ERROR(( "cff_get_name_index:" " cannot get glyph index from a CFF2 font\n" " " " without the `psnames' module\n" )); return 0; } } FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); if ( !psnames ) return 0; for ( i = 0; i < cff->num_glyphs; i++ ) { sid = charset->sids[i]; if ( sid > 390 ) name = cff_index_get_string( cff, sid - 391 ); else name = (FT_String *)psnames->adobe_std_strings( sid ); if ( !name ) continue; if ( !ft_strcmp( glyph_name, name ) ) return i; } return 0; }