diff options
-rw-r--r-- | tomacbinary.c | 1 | ||||
-rw-r--r-- | ufondbdf.c | 33 |
2 files changed, 24 insertions, 10 deletions
diff --git a/tomacbinary.c b/tomacbinary.c index e1f297f..0500140 100644 --- a/tomacbinary.c +++ b/tomacbinary.c @@ -50,6 +50,7 @@ /* MacBinary files use the same CRC that binhex does (in the MacBinary header) */ extern unsigned long binhex_crc(unsigned char *buffer,int size); +/* the resource fork may be opened (on Mac OS/X) by <filename>/rsrc */ /* tobin [-res rfilename] filename {[-res filename] rfilename} */ @@ -233,10 +233,16 @@ static void ParseBdfHeader(struct macfont *macfont, struct bdffont *bdf) { static int ParseCharWidths(struct macfont *macfont,int ch,char **chlist,int loc) { int pwidth=0, swidth=0, gwidth=0, lb=0; - - sscanf(chlist[2],"SWIDTH %d", &swidth ); - sscanf(chlist[3],"DWIDTH %d", &pwidth ); - sscanf(chlist[4],"BBX %d %*d %d", &gwidth, &lb ); + int i; + + for ( i=0 ; chlist[i]!=NULL; ++i ) { + if ( strncmp(chlist[i],"SWIDTH", 6)==0 ) + sscanf(chlist[i],"SWIDTH %d", &swidth ); + else if ( strncmp(chlist[i],"DWIDTH", 6)==0 ) + sscanf(chlist[i],"DWIDTH %d", &pwidth ); + else if ( strncmp(chlist[i],"BBX", 3)==0 ) + sscanf(chlist[i],"BBX %d %*d %d", &gwidth, &lb ); + } macfont->widths[ch] = pwidth; macfont->lbearings[ch] = lb; @@ -310,13 +316,20 @@ return; } static void ParseBitmap(struct macfont *macfont,int ch,char **chlist) { - int height, descent, ascent,off,i; + int height, descent, ascent,off,i, base; - sscanf(chlist[4],"BBX %*d %d %*d %d", &height, &descent ); - ascent = height+descent; - off = macfont->ascent-ascent; - for ( i=0; i<height; ++i ) - ParseRow(macfont,ch,i+off,chlist[i+6]); + for ( base=0 ; chlist[base]!=NULL; ++base ) { + if ( strncmp(chlist[base],"BBX",3)==0 ) + sscanf(chlist[base],"BBX %*d %d %*d %d", &height, &descent ); + else if ( strncmp(chlist[base],"BITMAP",6)==0 ) + break; + } + if ( chlist[base]!=NULL ) { + ascent = height+descent; + off = macfont->ascent-ascent; + for ( i=0; i<height; ++i ) + ParseRow(macfont,ch,i+off,chlist[i+base+1]); + } } static void DummyUpFakeBitmap(struct macfont *macfont,int ch) { |