Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!mcsun!hp4nl!nlbull!jos From: jos@bull.nl (Jos Vos) Newsgroups: comp.lang.postscript Subject: Converting PFB files to PostScript Message-ID: <1029@nlbull.bull.nl> Date: 26 Apr 91 07:08:29 GMT Organization: Bull, P.O. Box 22859, NL-1100 DJ Amsterdam, The Netherlands Lines: 313 As response to various questions in this newsgroup, here's a program to convert PFB files to a PostScript program that downloads the font. It was not written by me: see the NOTICE at the beginning of the program. In order to load the font permanently, insert the following line in the beginning of the output from the program: 0 serverdict begin exitserver Here's the program: ------------------CUT HERE /* * NOTICE * * Copyright 1988, 1989 by h-three Systems Corporation. * * Permission is hereby granted for this software's free reproduction * and modification for non-commercial purposes, provided that this * notice is retained. Commercial enterprises may give away copies * as part of their products provided that they do so without charge, * that they retain this notice, and that they acknowledge the source * of the software. * * PostScript is a registered trademark of Adobe Systems Incorporated. * IBM is a registered trademark of International Business Machines * Corporation. * * h-three Systems Corporation * 100 Park Drive Suite 204/ P.O. Box 12557 * Research Triangle Park, NC 27709 * * CHANGE HISTORY * * - A small change was made by Jos Vos to generate * a PostScript program with a '\n' ('\012') as line separator * i.s.o. a '\r' ('\015'). */ #ifdef NOWHAT static char *sccsid = "%W% - %E%"; #endif /* * unfont.c * * usage: unfont [ -v ] [ files ] * -v Prints execution information on the standard error. * * Unpacks IBM PC-format PostScript fonts into a downloadable form. * */ char *USAGE = "\ usage: unfont [ -? ] [ -v ] [files ]\n\ -? Prints this message.\n\ -v Prints execution information on the standard error.\n\ "; #include #include #include #include #define OK 0 #define FAILURE (-1) #define Failed(x) ((x) == FAILURE) #define TRUE 1 #define FALSE 0 typedef char bool; #define STREQ(a,b) (strcmp(a,b) == 0) FILE *fp; /* * used to convert nibbles (n0 is least sig) to ascii-hex */ #define N0(c) hexbyt[((c) & 0x000f)] #define N1(c) N0((c) >> 4) char hexbyt[] = "0123456789ABCDEF"; /* * vars controlled by command line options */ bool verbose = FALSE; /* be verbose */ extern char *optarg; /* getopt(3) control vars */ extern int optind; extern int errno; char *infile; char *progname; /* for error() */ char *strchr(), *strrchr(); long stol(), getparm(); int mygetc(); void dounfont(); long getcount(); void bintohex(); main(argc, argv) int argc; char **argv; { register int c; bool showusage = FALSE; /* usage error? */ /* * figure out invocation leaf-name */ if ((progname = strrchr(argv[0], '/')) == (char *) NULL) progname = argv[0]; else progname++; argv[0] = progname; /* for getopt err reporting */ /* * Check options and arguments. */ progname = argv[0]; while ((c = getopt(argc, argv, "v")) != EOF) switch (c) { case 'v': /* toggle verbose */ verbose = ! verbose; break; case '?': showusage = TRUE; } if (showusage) { (void) fprintf(stderr, "%s", USAGE); exit(1); } /* unfont stuff */ if (argv[optind]) { for ( ; argv[optind]; optind++) { if (!(fp = fopen(argv[optind], "r"))) { error(0, "can't open input file '%s'", argv[optind]); continue; } infile = argv[optind]; dounfont(); close(fp); } } else { infile = ""; fp = stdin; dounfont(); } exit(0); } long getcount(); void dounfont() { register int c; register int ch; long count; register int i; for (;;) { if ((c = mygetc()) != 0x80) { error(0, "not a proper font data segment '%s'", infile); error(0, "foobar char is 0x%x", c); exit(1); } c = mygetc(); switch (c) { case 1: /* get count, output count bytes to stdout */ count = getcount(); if (verbose) fprintf(stderr, "case1 count is %ld\n", count); for (i=0; i: ' * If 'errn' is non-zero, it is assumed to be an 'errno' and its * associated error message is appended to the output. */ /*VARARGS*/ error(errn, va_alist) int errn; va_dcl { va_list arglist; register char *format; extern char *sys_errlist[]; extern int sys_nerr; extern int errno; if (errn == -1) /* use errno if -1 */ errn = errno; va_start(arglist); format = va_arg(arglist, char *); (void) fprintf(stderr, "%s: ", progname); (void) vfprintf(stderr, format, arglist); va_end(arglist); if (errn) if ((errn > 0) && (errn <= sys_nerr)) (void) fprintf(stderr, " (%s)\n", sys_errlist[errn]); else (void) fprintf(stderr, " (unknown errno=%d)\n", errn); else (void) fprintf(stderr, "\n"); } ------------------CUT HERE -- -- Jos Vos (UUCP: ...!{uunet,mcsun,hp4nl}!nlbull!jos) -- Bull Nederland NV, Product Support Unix, Amsterdam, The Netherlands