summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Williams <gww@silcom.com>2001-11-12 08:08:35 +0000
committerGeorge Williams <gww@silcom.com>2001-11-12 08:08:35 +0000
commit5cef931ff57c8bc8259cc97d11a86782f885488e (patch)
treeb54478d27f966db3ee05a2aff1713bfbf678cd9a
parent0bd8f845ad35973e10656118f7a309164695b9c8 (diff)
small fixes
-rw-r--r--fondu.c16
-rw-r--r--readnfnt.c19
2 files changed, 25 insertions, 10 deletions
diff --git a/fondu.c b/fondu.c
index 62044fd..b2e2aa9 100644
--- a/fondu.c
+++ b/fondu.c
@@ -350,7 +350,8 @@ static void SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,long rdat
int len, type, i, rlen;
/* I don't pretend to understand the rational behind the format of a */
/* postscript font. It appears to be split up into chunks where the */
- /* maximum chunk size is 0x800 */
+ /* maximum chunk size is 0x800, each section (ascii, binary, ascii, eof) */
+ /* has its own set of chunks (ie chunks don't cross sections) */
char *buffer=NULL;
int max = 0;
FILE *pfb;
@@ -378,7 +379,7 @@ static void SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,long rdat
pfb = fopen( name,"w" );
if ( pfb==NULL ) {
- fprintf( stderr, "Can't open temporary file for postscript output\n", name );
+ fprintf( stderr, "Can't open temporary file for postscript output\n" );
fseek(f,here,SEEK_SET );
free(offsets);
return;
@@ -407,6 +408,8 @@ return;
putc((len>>8)&0xff,pfb);
putc(len&0xff,pfb);
fseek(pfb,hold,SEEK_SET);
+ if ( ch1==5 ) /* end of font mark */
+ break;
putc(0x80,pfb);
putc(ch1,pfb);
lenpos = ftell(pfb);
@@ -422,6 +425,10 @@ return;
max = rlen;
if ( max<0x800 ) max = 0x800;
buffer=malloc(max);
+ if ( buffer==NULL ) {
+ fprintf( stderr, "Out of memory\n" );
+ exit( 1 );
+ }
}
fread(buffer,1,rlen,f);
if ( type==1 ) {
@@ -567,6 +574,7 @@ static void SearchTtfResources(FILE *f,long rlistpos,int subcnt,long rdata_pos,
fseek(f,rlistpos,SEEK_SET);
for ( i=0; i<subcnt; ++i ) {
+ /* resource id = */ getushort(f);
rname = (short) getushort(f);
/* flags = */ getc(f);
ch1 = getc(f); ch2 = getc(f);
@@ -686,7 +694,7 @@ return( false );
if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 ||
header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 )
return( false );
- offset = (header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56] ;
+ offset = 128+((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]);
return( IsResourceFork(f,offset));
}
@@ -777,6 +785,8 @@ return( false );
}
ret = IsResourceFork(binary,ftell(binary)+dlen+2);
+
+ rewind(binary);
fclose(binary);
return( ret );
}
diff --git a/readnfnt.c b/readnfnt.c
index c55794d..231c90e 100644
--- a/readnfnt.c
+++ b/readnfnt.c
@@ -328,21 +328,25 @@ static void DumpNFNT2BDF(FILE *bdf,struct MacFontRec *font, char *resname,
int style = ass!=NULL ? ass->style : 0;
int size = ass!=NULL ? ass->size : font->fRectHeight;
int i;
+ int dpi = 75;
+
+ if ( size==17 || size==33 )
+ dpi = 100;
cnt = GetFontCount(font);
avg = GetFontAvgWidth(font);
fprintf(bdf,"STARTFONT 2.1\n");
- fprintf(bdf, "FONT -Fondu-%s-%s-%s-%s--%d-%d0-75-75-%s-%d-%s-1\n",
+ fprintf(bdf, "FONT -Fondu-%s-%s-%s-%s--%d-%d0-%d-%d-%s-%d-%s-1\n",
(mine!=NULL && mine->fondname!=NULL)?mine->fondname:resname,
(style&sf_bold)?"Bold":"Medium",
(style&sf_italic)?"I":"R",
(style&sf_condense)?"Condensed":(style&sf_extend)?"Extended":"Normal",
- size, (size*72+37)/75,
+ size, (size*72+dpi/2)/dpi, dpi, dpi,
(font->fontType&0xf000)==0xb000?"M":"P",
avg,
- tolatin1?"MacRoman":"ISO8859" );
+ tolatin1?"ISO8859":"MacRoman" );
- fprintf(bdf, "SIZE %d 75 75\n", (size*72+37)/75 );
+ fprintf(bdf, "SIZE %d %d %d\n", (size*72+dpi/2)/dpi, dpi, dpi );
fprintf(bdf, "FONTBOUNDINGBOX %d %d %d %d\n", font->fRectWidth, font->fRectHeight, font->kernMax, -font->descent );
fprintf(bdf, "COMMENT Created by Fondu from a mac NFNT/FONT resource\n" );
fprintf(bdf, "STARTPROPERTIES 17\n" );
@@ -353,9 +357,9 @@ static void DumpNFNT2BDF(FILE *bdf,struct MacFontRec *font, char *resname,
fprintf(bdf, "SETWIDTH_NAME \"%s\"\n", (style&sf_condense)?"Condensed":(style&sf_extend)?"Extended":"Normal" );
fprintf(bdf, "ADD_STYLE_NAME \"\"\n" );
fprintf(bdf, "PIXEL_SIZE %d\n", size );
- fprintf(bdf, "POINT_SIZE %d0\n", (size*72+37)/75 );
- fprintf(bdf, "RESOLUTION_X 75\n" );
- fprintf(bdf, "RESOLUTION_Y 75\n" );
+ fprintf(bdf, "POINT_SIZE %d0\n", (size*72+dpi/2)/dpi );
+ fprintf(bdf, "RESOLUTION_X %d\n", dpi );
+ fprintf(bdf, "RESOLUTION_Y %d\n", dpi );
fprintf(bdf, "SPACING \"%s\"\n", (font->fontType&0xf000)==0xb000?"M":"P");
fprintf(bdf, "AVERAGE_WIDTH %d\n", avg );
fprintf(bdf, "CHARSET_REGISTRY \"%s\"\n",tolatin1?"ISO8859":"MacRoman" );
@@ -411,6 +415,7 @@ void SearchNFNTResources(FILE *f,long rlistpos,int subcnt,long rdata_pos,
fseek(f,rlistpos,SEEK_SET);
for ( i=0; i<subcnt; ++i ) {
+ res_id = getushort(f);
rname = (short) getushort(f);
/* flags = */ getc(f);
ch1 = getc(f); ch2 = getc(f);