Path: utzoo!attcan!utgpu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!math.lsa.umich.edu!math.lsa.umich.edu!emv From: shiva@well.sf.ca.us (Kenneth Porter) Newsgroups: alt.sources Subject: [postscript] Re: PostScript downloadable font formats Keywords: postscript font download Message-ID: <1990Sep30.201844.29357@math.lsa.umich.edu> Date: 30 Sep 90 20:18:44 GMT References: <64@frcs.UUCP> <1579@chinacat.Unicom.COM> <20831@well.sf.ca.us> Sender: emv@math.lsa.umich.edu (Edward Vielmetti) Reply-To: shiva@well.sf.ca.us (Kenneth Porter) Followup-To: comp.lang.postscript Organization: (none) Lines: 259 X-Original-Newsgroups: comp.lang.postscript Archive-name: pfb2pfa/28-Sep-90 Original-posting-by: shiva@well.sf.ca.us (Kenneth Porter) Original-subject: Re: PostScript downloadable font formats Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti) [Reposted from comp.lang.postscript. Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).] Sorry Woody, my PC fonts arrived in binary form, and I had to use Adobe's downloader to decrypt them. I used my Sun 386i DOS window to capture the ASCII output to a file. Once I had more time, I wrote a program to decrypt the Adobe binary format. /* Decompress .pfb file into .pfa file */ /* Copyright 1990 Kenneth Porter (shiva@well.sf.ca.us) This is freely re-distributable, NOT public domain. Adobe PostScript font files are distributed in a compressed binary format to be decompressed and downloaded to the printer by Adobe's download utilities. Since we want to download the fonts ourselves, this utility is necessary to convert the binary file into an ASCII file readable by the printer. */ #include #include #include /* pfb record types */ #define PFBTXT 0x180 /* followed by long byte count */ #define PFBBIN 0x280 /* followed by long byte count */ #define PFBEOF 0x380 char *ExitServerString = "%!PS-Adobe-2.0 ExitServer\n" "%%BeginExitServer: 0\n" "serverdict begin 0 exitserver\n" "%%EndExitServer\n"; int Mac2IBM(FILE *mac, FILE *ibm, unsigned long count); int Bin2Txt(FILE *bin, FILE *txt, unsigned long count); FILE *srcopen(char *name); FILE *dstopen(char *name); FILE *fileopen(char *name, char *mode, char *humanmode); unsigned long fgetl(FILE *f); void ExitServer(char *tempfile,char *dstfile); void CheckFontName(char *linebuf); void main(int argc, char *argv[]) { FILE *pfb, *pfa; unsigned long count; int eof = 0; unsigned rtype; /* pfb record type */ char temp[L_tmpnam]; banner(); if (argc < 3 || argc > 4) { fprintf(stderr,"syntax: %s [persistent]\n",argv[0]); exit(1); } pfb = srcopen(argv[1]); pfa = dstopen(tmpnam(temp)); while (!eof) { rtype = getw(pfb); if (feof(pfb)) { fprintf(stderr,"Unexpected end of file\n"); break; } switch (rtype) { case PFBEOF: eof = 1; break; case PFBTXT: count = fgetl(pfb); printf("Text count = %ld\n",count); if (feof(pfb)) { fprintf(stderr,"Unexpected end of file\n"); eof = 1; break; } if (Mac2IBM(pfb,pfa,count)) { fprintf(stderr,"Unexpected end of file\n"); eof = 1; break; } break; case PFBBIN: count = fgetl(pfb); printf("Bin count = %ld\n",count); if (feof(pfb)) { fprintf(stderr,"Unexpected end of file\n"); eof = 1; break; } if (Bin2Txt(pfb,pfa,count)) { fprintf(stderr,"Unexpected end of file\n"); eof = 1; break; } break; default: fprintf(stderr,"Record type %X not recognized\n",rtype); eof = 1; break; } } fclose(pfa); fclose(pfb); if (argc == 4) ExitServer(temp,argv[2]); else rename(temp,argv[2]); exit(0); } #define CR 13 /* Mac ends line with carriage return, IBM with CRLF */ int Mac2IBM(FILE *mac, FILE *ibm, unsigned long count) { int c; char *lp; static char linebuf[128]; linebuf[0] = 0; lp = linebuf; while (count--) { c = fgetc(mac); if (feof(mac)) return(EOF); if (c == CR) { fputc('\n',ibm); *lp = 0; CheckFontName(linebuf); linebuf[0] = 0; lp = linebuf; } else { fputc(c,ibm); *lp++ = c; } } *lp = 0; CheckFontName(linebuf); return(0); } int Bin2Txt(FILE *bin, FILE *txt, unsigned long count) { int c; unsigned long i; for (i=0; i