summaryrefslogtreecommitdiff
path: root/fondu.c
diff options
context:
space:
mode:
Diffstat (limited to 'fondu.c')
-rw-r--r--fondu.c16
1 files changed, 13 insertions, 3 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 );
}