static void IkarusNameFromURWNumber(SplineChar *sc,int number) { char buf[200]; if ( !urw_inited ) InitURWTable(); free(sc->name); sc->name = NULL; if ( number<sizeof(urwtable)/sizeof(urwtable[0]) ) { sc->unicodeenc = urwtable[number]; if ( sc->unicodeenc!=-1 ) { sc->name = copy(StdGlyphName(buf,sc->unicodeenc,ui_none,NULL)); return; } } if ( number==1059 ) sc->name = copy("apple"); else if ( number==795 ) sc->name = copy("copyright.big"); else if ( number==796 ) sc->name = copy("registered.big"); else { sprintf(buf, "urw%d", number ); sc->name = copy(buf); } }
/* * There is no check if a glyph with the same unicode exists! * TODO: let FontForge fill in the standard glyph name <- or maybe this might cause collision? */ void ffw_add_empty_char(int32_t unicode, int width) { SplineChar * sc = SFMakeChar(cur_fv->sf, cur_fv->map, cur_fv->map->enccount); char buffer[400]; SCSetMetaData(sc, strcopy(StdGlyphName(buffer, unicode, cur_fv->sf->uni_interp, cur_fv->sf->for_new_glyphs)), unicode, sc->comment); SCSynchronizeWidth(sc, width, sc->width, cur_fv); }
int CID2NameUni(struct cidmap *map,int cid, char *buffer, int len) { int enc = -1; const char *temp; #if defined( _NO_SNPRINTF ) || defined( __VMS ) if ( map==NULL ) sprintf(buffer,"cid-%d", cid); else if ( cid<map->namemax && map->name[cid]!=NULL ) strncpy(buffer,map->name[cid],len); else if ( cid==0 || (cid<map->namemax && map->unicode[cid]!=0 )) { if ( map->unicode==NULL || map->namemax==0 ) enc = 0; else enc = map->unicode[cid]; temp = StdGlyphName(buffer,enc,ui_none,(NameList *) -1); if ( temp!=buffer ) strcpy(buffer,temp); } else sprintf(buffer,"%s.%d", map->ordering, cid); #else if ( map==NULL ) snprintf(buffer,len,"cid-%d", cid); else if ( cid<map->namemax && map->name[cid]!=NULL ) strncpy(buffer,map->name[cid],len); else if ( cid==0 ) strcpy(buffer,".notdef"); else if ( cid<map->namemax && map->unicode[cid]!=0 ) { if ( map->unicode==NULL || map->namemax==0 ) enc = 0; else enc = map->unicode[cid]; temp = StdGlyphName(buffer,enc,ui_none,(NameList *) -1); if ( temp!=buffer ) strcpy(buffer,temp); } else snprintf(buffer,len,"%s.%d", map->ordering, cid); #endif return( enc ); }
SplineChar *SCBuildDummy(SplineChar *dummy,SplineFont *sf,EncMap *map,int i) { static char namebuf[100]; static Layer layers[2]; memset(dummy,'\0',sizeof(*dummy)); dummy->color = COLOR_DEFAULT; dummy->layer_cnt = 2; dummy->layers = layers; if ( sf->cidmaster!=NULL ) { /* CID fonts don't have encodings, instead we must look up the cid */ if ( sf->cidmaster->loading_cid_map ) dummy->unicodeenc = -1; else dummy->unicodeenc = CID2NameUni(FindCidMap(sf->cidmaster->cidregistry,sf->cidmaster->ordering,sf->cidmaster->supplement,sf->cidmaster), i,namebuf,sizeof(namebuf)); } else dummy->unicodeenc = UniFromEnc(i,map->enc); if ( sf->cidmaster!=NULL ) dummy->name = namebuf; else if ( map->enc->psnames!=NULL && i<map->enc->char_cnt && map->enc->psnames[i]!=NULL ) dummy->name = map->enc->psnames[i]; else if ( dummy->unicodeenc==-1 ) dummy->name = NULL; else dummy->name = (char *) StdGlyphName(namebuf,dummy->unicodeenc,sf->uni_interp,sf->for_new_glyphs); if ( dummy->name==NULL ) { /*if ( dummy->unicodeenc!=-1 || i<256 ) dummy->name = ".notdef"; else*/ { int j; sprintf( namebuf, "NameMe.%d", i); j=0; while ( SFFindExistingSlot(sf,-1,namebuf)!=-1 ) sprintf( namebuf, "NameMe.%d.%d", i, ++j); dummy->name = namebuf; } } dummy->width = dummy->vwidth = sf->ascent+sf->descent; if ( dummy->unicodeenc>0 && dummy->unicodeenc<0x10000 && iscombining(dummy->unicodeenc)) { /* Mark characters should be 0 width */ dummy->width = 0; /* Except in monospaced fonts on windows, where they should be the */ /* same width as everything else */ } /* Actually, in a monospace font, all glyphs should be the same width */ /* whether mark or not */ if ( sf->pfminfo.panose_set && sf->pfminfo.panose[3]==9 && sf->glyphcnt>0 ) { for ( i=sf->glyphcnt-1; i>=0; --i ) if ( SCWorthOutputting(sf->glyphs[i])) { dummy->width = sf->glyphs[i]->width; break; } } dummy->parent = sf; dummy->orig_pos = 0xffff; return( dummy ); }