summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Williams <pfaedit@users.sourceforge.net>2011-02-16 14:03:17 -0800
committerGeorge Williams <pfaedit@users.sourceforge.net>2011-02-16 14:03:17 -0800
commit12f366575800ca18ee98ad85f2d7461e5ae029dc (patch)
tree20dfd98b45b54b16cf9b1481905f78405989ea70
parent23333560dd09506a41e1ad552734fc231d7391f5 (diff)
Correct two "bugs" in UFO output. I believe that I was following the spec in both cases, but since the reference implimentation does not follow the spec I shall do what it does instead.
1) The spec gives a complex algorithm for converting a glyph name to a filename. The proper behavior appears to be "add an underscore immediately after every capital letter" and leave it at that. 2) The spec says for OS2 fsType we should output bit numbers. It doesn't mean the numbers of the bits (0..15) but rather the values (0..1).
-rw-r--r--fontforge/ufo.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/fontforge/ufo.c b/fontforge/ufo.c
index b6dc323f..18be4bab 100644
--- a/fontforge/ufo.c
+++ b/fontforge/ufo.c
@@ -545,11 +545,11 @@ return( false );
{
int fscnt,i;
char fstype[16];
+ /* Now the spec SAYS we should output bit >numbers<. */
+ /* What is MEANT is that bit >values< should be output. */
for ( i=fscnt=0; i<16; ++i )
- if ( sf->pfminfo.fstype&(1<<i) )
- fstype[fscnt++] = i;
- if ( fscnt!=0 )
- PListOutputIntArray(plist,"openTypeOS2Type",fstype,fscnt);
+ fstype[fscnt++] = sf->pfminfo.fstype&(1<<i) ? 1 : 0;
+ PListOutputIntArray(plist,"openTypeOS2Type",fstype,fscnt);
}
if ( sf->pfminfo.typoascent_add )
PListOutputInteger(plist,"openTypeOS2TypoAscender",sf->ascent+sf->pfminfo.os2_typoascent);
@@ -761,36 +761,37 @@ return( false );
}
for ( i=0; i<sf->glyphcnt; ++i ) if ( SCWorthOutputting(sc=sf->glyphs[i]) ) {
- gfname = galloc(strlen(sc->name)+20);
- if ( isupper(sc->name[0])) {
- char *pt;
- pt = strchr(sc->name,'.');
- if ( pt==NULL ) {
- strcpy(gfname,sc->name);
- strcat(gfname,"_");
- } else {
- strncpy(gfname,sc->name,pt-sc->name);
- gfname[pt-sc->name] = '_';
-#ifdef __VMS
- gfname[pt-sc->name+1] = '@';
- strcpy(gfname + (pt-sc->name) + 2,pt+1);
-#else
- strcpy(gfname + (pt-sc->name) + 1,pt);
-#endif
- }
- } else
+ char *start, *gstart;
+ gstart = gfname = galloc(2*strlen(sc->name)+20);
+ start = sc->name;
+ if ( *start=='.' ) {
+ *gstart++ = '_';
+ ++start;
+ }
+ while ( *start ) {
+ /* Now the spec has a very complicated algorithm for producing a */
+ /* filename, dividing the glyph name into chunks at every period*/
+ /* and then again at every underscore, and then adding an under-*/
+ /* score at the end of a chunk if the chunk begins with a capital*/
+ /* BUT... */
+ /* That's not what RoboFAB does. It simply adds an underscore after*/
+ /* every capital letter. Much easier. And since people have */
+ /* complained that I follow the spec, let's not. */
+ if ( isupper( *start )) {
+ *gstart++ = tolower( *start );
+ *gstart++ = '_';
+ } else
+ *gstart++ = *start;
+ ++start;
+ }
#ifdef __VMS
- {
- char *pt;
- strcpy(gfname,sc->name);
- for ( pt=gfname; *pt; ++pt )
- if ( *pt=='.' )
- *pt='@';
- }
-#else
- strcpy(gfname,sc->name);
+ *gstart ='\0';
+ for ( gstart=gfname; *gstart; ++gstart ) {
+ if ( *gstart=='.' )
+ *gstart = '@'; /* VMS only allows one "." in a filename */
+ }
#endif
- strcat(gfname,".glif");
+ strcpy(gstart,".glif");
PListOutputString(plist,sc->name,gfname);
err |= !GlifDump(glyphdir,gfname,sc,layer);
free(gfname);
@@ -1644,15 +1645,18 @@ return;
static long UFOGetBits(xmlDocPtr doc,xmlNodePtr value) {
xmlNodePtr kid;
- long mask=0;
+ long mask=0, bit;
if ( _xmlStrcmp(value->name,(const xmlChar *) "array")!=0 )
return( 0 );
+ bit = 1;
for ( kid = value->children; kid!=NULL; kid=kid->next ) {
if ( _xmlStrcmp(kid->name,(const xmlChar *) "integer")==0 ) {
char *valName = (char *) _xmlNodeListGetString(doc,kid->children,true);
- mask |= 1<<strtol(valName,NULL,10);
+ if ( strtol(valName,NULL,10))
+ mask |= bit;
free(valName);
+ bit<<=1;
}
}
return( mask );