summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Williams <gww@silcom.com>2003-11-04 19:42:06 +0000
committerGeorge Williams <gww@silcom.com>2003-11-04 19:42:06 +0000
commit62a4dbead286c3b4ebef16957cfc7df9fc632db7 (patch)
tree63f1e7a4e03f640d7f16b8ec2138bf76d6798abb
parent48796f6f4e279a82654092d7c09dbc60fa56ed9e (diff)
We had an overly simplistic bdf parser in ufond, which failed to read some bdf fonts properly.
-rw-r--r--tomacbinary.c1
-rw-r--r--ufondbdf.c33
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} */
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; 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) {