diff options
Diffstat (limited to 'contrib/groff/pfbtops')
-rw-r--r-- | contrib/groff/pfbtops/Makefile.dep | 1 | ||||
-rw-r--r-- | contrib/groff/pfbtops/Makefile.sub | 5 | ||||
-rw-r--r-- | contrib/groff/pfbtops/pfbtops.c | 112 | ||||
-rw-r--r-- | contrib/groff/pfbtops/pfbtops.man | 44 |
4 files changed, 162 insertions, 0 deletions
diff --git a/contrib/groff/pfbtops/Makefile.dep b/contrib/groff/pfbtops/Makefile.dep new file mode 100644 index 000000000000..f601c366ab97 --- /dev/null +++ b/contrib/groff/pfbtops/Makefile.dep @@ -0,0 +1 @@ +pfbtops.o: pfbtops.c diff --git a/contrib/groff/pfbtops/Makefile.sub b/contrib/groff/pfbtops/Makefile.sub new file mode 100644 index 000000000000..a06748e775cf --- /dev/null +++ b/contrib/groff/pfbtops/Makefile.sub @@ -0,0 +1,5 @@ +PROG=pfbtops +MAN1=pfbtops.n +OBJS=pfbtops.o +CSRCS=pfbtops.c +XLIBS=$(LIBGROFF) diff --git a/contrib/groff/pfbtops/pfbtops.c b/contrib/groff/pfbtops/pfbtops.c new file mode 100644 index 000000000000..fb370ab79dfc --- /dev/null +++ b/contrib/groff/pfbtops/pfbtops.c @@ -0,0 +1,112 @@ +/* This translates ps fonts in .pfb format to ASCII ps files. */ + +#include <stdio.h> + +/* Binary bytes per output line. */ +#define BYTES_PER_LINE (64/2) +#define HEX_DIGITS "0123456789abcdef" + +static char *program_name; + +static void error(s) + char *s; +{ + fprintf(stderr, "%s: %s\n", program_name, s); + exit(2); +} + +static void usage() +{ + fprintf(stderr, "usage: %s [-v] [pfb_file]\n", program_name); + exit(1); +} + +int main(argc, argv) + int argc; + char **argv; +{ + int opt; + extern int optind; + + program_name = argv[0]; + + while ((opt = getopt(argc, argv, "v")) != EOF) { + switch (opt) { + case 'v': + { + extern char *version_string; + fprintf(stderr, "pfbtops groff version %s\n", version_string); + fflush(stderr); + break; + } + case '?': + usage(); + } + } + + if (argc - optind > 1) + usage(); + if (argc > optind && !freopen(argv[optind], "r", stdin)) + { + perror(argv[optind]); + exit(1); + } + for (;;) + { + int type, c, i; + long n; + + c = getchar(); + if (c != 0x80) + error("first byte of packet not 0x80"); + type = getchar(); + if (type == 3) + break; + if (type != 1 && type != 2) + error("bad packet type"); + n = 0; + for (i = 0; i < 4; i++) + { + c = getchar(); + if (c == EOF) + error("end of file in packet header"); + n |= (long)c << (i << 3); + } + if (n < 0) + error("negative packet length"); + if (type == 1) + { + while (--n >= 0) + { + c = getchar(); + if (c == EOF) + error("end of file in text packet"); + if (c == '\r') + c = '\n'; + putchar(c); + } + if (c != '\n') + putchar('\n'); + } + else + { + int count = 0; + while (--n >= 0) + { + c = getchar(); + if (c == EOF) + error("end of file in binary packet"); + if (count >= BYTES_PER_LINE) + { + putchar('\n'); + count = 0; + } + count++; + putchar(HEX_DIGITS[(c >> 4) & 0xf]); + putchar(HEX_DIGITS[c & 0xf]); + } + putchar('\n'); + } + } + exit(0); +} diff --git a/contrib/groff/pfbtops/pfbtops.man b/contrib/groff/pfbtops/pfbtops.man new file mode 100644 index 000000000000..cfef3e0a1033 --- /dev/null +++ b/contrib/groff/pfbtops/pfbtops.man @@ -0,0 +1,44 @@ +.ig \"-*- nroff -*- +Copyright (C) 1989-1995 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be included in +translations approved by the Free Software Foundation instead of in +the original English. +.. +.TH PFBTOPS @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +.SH NAME +pfbtops \- translate a PostScript font in .pfb format to ASCII +.SH SYNOPSIS +.B pfbtops +[ +.I pfb_file +] +.SH DESCRIPTION +.B pfbtops +translates a PostScript font in +.B .pfb +format to ASCII. +If +.I pfb_file +is omitted the pfb file will be read from the standard input. +The ASCII format PostScript font will be written on the standard output. +PostScript fonts for MS-DOS are normally supplied in +.B .pfb +format. +.LP +The resulting ASCII format PostScript font can be used with groff. +It must first be listed in +.BR @FONTDIR@/devps/download . +.SH "SEE ALSO" +.BR grops (@MAN1EXT@) |