/* * TT CMAP INFO * * If the charmap is a synthetic Unicode encoding cmap or * a Type 1 standard (or expert) encoding cmap, hide TT CMAP INFO * service defined in SFNT module. * * Otherwise call the service function in the sfnt module. * */ static FT_Error cff_get_cmap_info( FT_CharMap charmap, TT_CMapInfo *cmap_info ) { FT_CMap cmap = FT_CMAP( charmap ); FT_Error error = CFF_Err_Ok; cmap_info->language = 0; if ( cmap->clazz != &cff_cmap_encoding_class_rec && cmap->clazz != &cff_cmap_unicode_class_rec ) { FT_Face face = FT_CMAP_FACE( cmap ); FT_Library library = FT_FACE_LIBRARY( face ); FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Service_TTCMaps service = (FT_Service_TTCMaps)ft_module_get_service( sfnt, FT_SERVICE_ID_TT_CMAP ); if ( service && service->get_cmap_info ) error = service->get_cmap_info( charmap, cmap_info ); } return error; }
/* * TT CMAP INFO * * If the charmap is a synthetic Unicode encoding cmap or * a Type 1 standard (or expert) encoding cmap, hide TT CMAP INFO * service defined in SFNT module. * * Otherwise call the service function in the sfnt module. * */ static FT_Error cff_get_cmap_info( FT_CharMap charmap, TT_CMapInfo *cmap_info ) { FT_CMap cmap = FT_CMAP( charmap ); FT_Error error = CFF_Err_Ok; FT_Face face = FT_CMAP_FACE( cmap ); FT_Library library = FT_FACE_LIBRARY( face ); cmap_info->language = 0; cmap_info->format = 0; if ( cmap->clazz != &FT_CFF_CMAP_ENCODING_CLASS_REC_GET && cmap->clazz != &FT_CFF_CMAP_UNICODE_CLASS_REC_GET ) { FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Service_TTCMaps service = (FT_Service_TTCMaps)ft_module_get_service( sfnt, FT_SERVICE_ID_TT_CMAP ); if ( service && service->get_cmap_info ) error = service->get_cmap_info( charmap, cmap_info ); } return error; }
static const char* cff_get_ps_name( CFF_Face face ) { CFF_Font cff = (CFF_Font)face->extra.data; SFNT_Service sfnt = (SFNT_Service)face->sfnt; /* following the OpenType specification 1.7, we return the name stored */ /* in the `name' table for a CFF wrapped into an SFNT container */ if ( FT_IS_SFNT( FT_FACE( face ) ) && sfnt ) { FT_Library library = FT_FACE_LIBRARY( face ); FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); FT_Service_PsFontName service = (FT_Service_PsFontName)ft_module_get_service( sfnt_module, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, 0 ); if ( service && service->get_ps_font_name ) return service->get_ps_font_name( FT_FACE( face ) ); } return (const char*)cff->font_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; }
static FT_Error cff_get_glyph_name( CFF_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) { CFF_Font font = (CFF_Font)face->extra.data; FT_String* gname; FT_UShort sid; FT_Error error; /* CFF2 table does not have glyph names; */ /* we need to use `post' table method */ if ( font->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->get_name ) return service->get_name( FT_FACE( face ), glyph_index, buffer, buffer_max ); else { FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from a CFF2 font\n" " " " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } } if ( !font->psnames ) { FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from CFF & CEF fonts\n" " " " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } /* first, locate the sid in the charset table */ sid = font->charset.sids[glyph_index]; /* now, lookup the name itself */ gname = cff_index_get_sid_string( font, sid ); if ( gname ) FT_STRCPYN( buffer, gname, buffer_max ); error = FT_Err_Ok; Exit: return error; }