From 62a4dbead286c3b4ebef16957cfc7df9fc632db7 Mon Sep 17 00:00:00 2001 From: George Williams Date: Tue, 4 Nov 2003 19:42:06 +0000 Subject: We had an overly simplistic bdf parser in ufond, which failed to read some bdf fonts properly. --- tomacbinary.c | 1 + 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 /rsrc */ /* tobin [-res rfilename] filename {[-res filename] rfilename} */ diff --git a/ufondbdf.c b/ufondbdf.c index 58ade0d..fe3ef89 100644 --- a/ufondbdf.c +++ b/ufondbdf.c @@ -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; iascent-ascent; + for ( i=0; i