summaryrefslogtreecommitdiff
path: root/graphics/pbmtopk/pbmtopk
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/pbmtopk/pbmtopk
Initial commit
Diffstat (limited to 'graphics/pbmtopk/pbmtopk')
-rw-r--r--graphics/pbmtopk/pbmtopk/Makefile28
-rw-r--r--graphics/pbmtopk/pbmtopk/face.pbm66
-rw-r--r--graphics/pbmtopk/pbmtopk/pbmtopk.173
-rw-r--r--graphics/pbmtopk/pbmtopk/pbmtopk.c1050
-rw-r--r--graphics/pbmtopk/pbmtopk/pktopbm.117
-rw-r--r--graphics/pbmtopk/pbmtopk/pktopbm.c381
-rw-r--r--graphics/pbmtopk/pbmtopk/sign.pbm302
-rw-r--r--graphics/pbmtopk/pbmtopk/test.opt8
-rw-r--r--graphics/pbmtopk/pbmtopk/test.tex11
9 files changed, 1936 insertions, 0 deletions
diff --git a/graphics/pbmtopk/pbmtopk/Makefile b/graphics/pbmtopk/pbmtopk/Makefile
new file mode 100644
index 0000000000..a1f21555e2
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/Makefile
@@ -0,0 +1,28 @@
+# Simple makefile for pbmtopk & pktopbm
+# AJCD 9/8/90
+
+#CC=gcc-1.37.1
+CFLAGS=-I. -O
+
+all: pbmtopk pktopbm
+
+test: test.dvi test.pbm
+
+pbmtopk: pbmtopk.c
+ $(CC) $(CFLAGS) -o pbmtopk pbmtopk.c -lpbm
+
+pktopbm: pktopbm.c
+ $(CC) $(CFLAGS) -o pktopbm pktopbm.c -lpbm
+
+test.pbm: pktopbm test.300pk
+ pktopbm test.300pk -c 65 test.pbm
+
+test.dvi: test.tex test.tfm
+ tex test
+
+test.300pk test.tfm: pbmtopk test.opt
+ pbmtopk test.300pk test.tfm 300 -s 10 -f test.opt
+
+clean:
+ rm -f pbmtopk pktopbm test.dvi test.log test.tfm test.300pk test.pbm
+
diff --git a/graphics/pbmtopk/pbmtopk/face.pbm b/graphics/pbmtopk/pbmtopk/face.pbm
new file mode 100644
index 0000000000..eb79666e15
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/face.pbm
@@ -0,0 +1,66 @@
+P1
+64 64
+0111110100000000010110101110101001000010100000010000000000001001
+0011011101011011010110111111011010010100000101000101000010100000
+1111101010000101011011011110101001010010101000010000010001000001
+0011110100101010110110111111110101011101000010100010100101011000
+1111011011001011101011111010101010101010010000010100001000110000
+0110110100101010111101011011111101011011010101010000010010000100
+1111010101010101101111111101100101010100101010101010100100000000
+0101010010101011011111010101011010110101010110101010010001000000
+1110100110111010111110101101010101111101101101101001001000000000
+0100010101010101011101010111101110101010111110101011010101001010
+0001001111010000000010010101110101010101010000000100100101010000
+0100011101010101001000101011011101101010101010000001010101010010
+0010110101101000000010000111110110101001000000000000010101010100
+1000111111010000010000010001010101010000010000000001010101010000
+0011110110101001000000000000100010000100000000000000101110101010
+0010111111010100000101000100001000000000000000000100011011010100
+0101011111100000010000000000000000000000000000000000111111110101
+0001111111110101000100000000000000000000000000000000011111111010
+0111111111000000000001000000000000000000100000000000111111111100
+1011111111101010001000010001000000000000000100010000011101111111
+0111111111010000000000000000000000000000000000000010111111111010
+0001110111100101001001000000001000000000000000000000011111111110
+0111111111010000000000000000000000000000000000100000111111011100
+0010111111101010100000000100000000000000000000000010011111111101
+0001111111000000000000100000000000000100000000000000111011111010
+1010111111010100000000000000100000100000000000000100011111110100
+0001011111000001001010010100001000000000000000000000011111111010
+0100111111110100010001010010100010010100010010000010001111110100
+0001011011000010101101111010001000101010100000000000011111110010
+0100101111001000010011110101100010101010100101010000101110111100
+0001011111100010101101001010010001010101110100000000011111110010
+0100000101001001010010110001000000010101110101010100001111101000
+0010001011000000000000000100000000000000001000000000010100011101
+1000100001010010000100100000100000000100100000000000000100000110
+0000001010000000100000000010000000100000000001000000010010010101
+0010100010101000000100100000100000000001000000000000000100001011
+0100000100000010000000000100000000000000000000000000100000000100
+0010101001011000000000000001000000000000001000000010000000010101
+1010111000100001000000000000010000000000000000000000000000100010
+0001110101000100000100001001000000001000000001001001001000010101
+0101110000101001000000000000000000000000000000000000000010001001
+0000111010010000010000100101010010100000000000010001001001010010
+0101001010100101000000000010100101010010000000000100000010101101
+0000100001010000000100000101011011100000010001000000001010000101
+0000001010100100100000100010101000010000000000001001010001010101
+0010100010010000000000001000100101000000000000000000001010101011
+0000001001000101001001000010001000000000000100010001010101010111
+0010101010010000000000001000100100001001000000000000010101001011
+0100010001000100100010100101010010000000010000100010011010100111
+1000101010010000001000010111111111110101000000000000001101001011
+0101010100100101000000001010101000101000000000010010100110101111
+1010010010001000000100100001010101000001001001000000001010101111
+0001101000100100100000000100101010010000000000001010101101011111
+0110010010010001001010100001000001000010001000100000001010101111
+1010101001000100010000001000010000001000000010001001101100111111
+0101010010000010100010100000000100000000101000100100010101011111
+1110101001010000010100000100000000000000000010000001111000111111
+1010100101001010100000100000000000000001001000010010110010111111
+0101010010010001001010001001001010010000010010000101100101110111
+1010100100000110010010100100100001000101001001000011010100111111
+0101001001010010001000100010010100101001000100000101101011111111
+1010100100101100100101001001001001010010010000000010010100111111
+0100010001001001000010101010010101001001000000000101101011111111
+0101000101010100010100010000100010010100000001000010011111111111
diff --git a/graphics/pbmtopk/pbmtopk/pbmtopk.1 b/graphics/pbmtopk/pbmtopk/pbmtopk.1
new file mode 100644
index 0000000000..d518356b99
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/pbmtopk.1
@@ -0,0 +1,73 @@
+.TH pbmtopk 1 "6 August 1990"
+.SH NAME
+pbmtopk - convert a portable bitmap into a packed (PK) format font
+.SH SYNOPSIS
+pbmtopk pkfile[.pk] tfmfile[.tfm] resolution [-s designsize] [-p num param...]
+[-C codingscheme] [-F family] [-f optfile] [-c num]
+[-W width] [-H height] [-D depth]
+[-I ital] [-h horiz] [-v vert] [-x xoff] [-y yoff] [pbmfile]...
+.SH DESCRIPTION
+Reads portable bitmaps as input, and produces a packed (PK) font file and a
+TFM (TeX font metric) file as output. The resolution parameter indicates the
+resolution of the font, in dots per inch. If the filename "-" is used for any
+of the filenames, the standard input stream (or standard output where
+appropriate) will be used.
+.SH OPTIONS
+.IP "-s designsize"
+Sets the design size of the font, in TeX's points (72.27pt to the inch). The
+default design size is 1. The TFM parameters are given as multiples of the
+design size.
+.IP "-p num param..."
+Sets the first num font parameters for the font. The first seven parameters
+are the slant,
+interword spacing, interword space stretchability, interword space
+shrinkability, x-height, quad width, and post-sentence extra space of the
+font. Math and symbol fonts may have more parameters; see The TeXbook for a
+list of these. Reasonable default values are chosen for parameters which are
+not specified.
+.IP "-C codingscheme"
+Sets the coding scheme comment in the TFM file.
+.IP "-F family"
+Sets the font family comment in the TFM file.
+.IP "-f optfile"
+Reads the file optfile, which should contain a lines of the form:
+.sp
+.nf
+.na
+ filename xoff yoff horiz vert width height depth ital
+.fi
+.ad
+.sp
+The pbm files specified by the filename parameters are inserted consecutively
+in the font with the specified attributes. If any of the attributes are
+omitted, or replaced with "*", a default value will be calculated from the
+size of the bitmap. The settings of the -W, -H, -D, -I, -h, -v, -x, and -y
+options do not affected characters created in this way.
+The character number can be changed by including a line starting with "=",
+followed by the new number.
+Lines beginning with
+"%" or "#" are ignored.
+.IP "-c num"
+Sets the character number of the next bitmap encountered to num.
+.IP "-W width"
+Sets the TFM width of the next character to width (in design size multiples).
+.IP "-H height"
+Sets the TFM height of the next character to height (in design size multiples).
+.IP "-D depth"
+Sets the TFM depth of the next character to depth (in design size multiples).
+.IP "-I ital"
+Sets the italic correction of the next character to
+ital (in design size multiples).
+.IP "-h horiz"
+Sets the horizontal escapement of the next character to horiz (in pixels).
+.IP "-v vert"
+Sets the vertical escapement of the next character to vert (in pixels).
+.IP "-x xoff"
+Sets the horizontal offset of the next character to xoff (in pixels).
+.IP "-y yoff"
+Sets the vertical offset of the next character to yoff (in pixels, from the
+top row).
+.SH "SEE ALSO"
+pktopbm(1), pbm(5)
+.SH AUTHOR
+Adapted from Tom Rokicki's pxtopk by Angus Duggan <ajcd@uk.ac.ed.lfcs>.
diff --git a/graphics/pbmtopk/pbmtopk/pbmtopk.c b/graphics/pbmtopk/pbmtopk/pbmtopk.c
new file mode 100644
index 0000000000..45696e9684
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/pbmtopk.c
@@ -0,0 +1,1050 @@
+/*
+ pbmtopk, adapted from "pxtopk.c by tomas rokicki" by AJCD 1/8/90
+
+ compile with: cc -o pbmtopk pbmtopk.c -lm -lpbm
+ */
+
+#include <stdio.h>
+#include <pbm.h>
+#include <ctype.h>
+
+extern double atof();
+
+#define MAXPKCHAR 256
+#define MAXOPTLINE 200
+#define MAXWIDTHTAB 256
+#define MAXHEIGHTTAB 16
+#define MAXDEPTHTAB 16
+#define MAXITALICTAB 64
+#define MAXPARAMS 30
+#define NAMELENGTH 80
+
+#define true (1)
+#define false (0)
+#define chr(a) a
+
+#define round(a) ((int)(a+.5))
+#define fixword(d) ((int)((double)(d)*1048576))
+#define unfixword(f) ((double)(f) / 1048576)
+#define fixrange(f) ((f) < 16777216 && (f) > -16777216)
+#define designunits(p) ((p)*72.27/(double)resolution/unfixword(designsize))
+
+/* character flags: in order of appearance in option files. */
+#define XOFFSET 1
+#define YOFFSET 2
+#define HORZESC 4
+#define VERTESC 8
+#define TFMWIDTH 16
+#define TFMHEIGHT 32
+#define TFMDEPTH 64
+#define TFMITALIC 128
+
+typedef int integer ;
+typedef char quarterword ;
+typedef char boolean ;
+typedef quarterword ASCIIcode ;
+typedef quarterword eightbits ;
+typedef FILE *bytefile ;
+typedef unsigned char byte ;
+
+integer resolution, designsize ;
+char *filename[MAXPKCHAR] ;
+
+integer xoffset[MAXPKCHAR] ;
+integer yoffset[MAXPKCHAR] ;
+integer horzesc[MAXPKCHAR] ;
+integer vertesc[MAXPKCHAR] ;
+
+byte tfmindex[MAXPKCHAR] ;
+byte hgtindex[MAXPKCHAR] ;
+byte depindex[MAXPKCHAR] ;
+byte italindex[MAXPKCHAR] ;
+byte charflags[MAXPKCHAR] ;
+
+bit **bitmap ;
+integer smallestch, largestch ;
+integer emwidth ;
+integer checksum ;
+char *codingscheme = "GRAPHIC" ;
+char *familyname = "PBM" ;
+
+integer widthtab[MAXWIDTHTAB] ; /* TFM widths */
+integer numwidth ; /* number of entries in width table */
+integer heighttab[MAXHEIGHTTAB] ;
+integer numheight ;
+integer depthtab[MAXDEPTHTAB] ;
+integer numdepth ;
+integer italictab[MAXITALICTAB] ;
+integer numitalic ;
+integer parameters[MAXPARAMS] ;
+integer numparam ;
+
+ASCIIcode xord[128] ;
+char xchr[256] ;
+bytefile tfmfile, pkfile ;
+char tfmname[NAMELENGTH+1], pkname[NAMELENGTH+1] ;
+integer pkloc ;
+integer bitweight ;
+integer outputbyte ;
+integer car ;
+integer hppp ;
+integer width ;
+integer height ;
+integer power[32] ;
+
+integer
+compute_checksum()
+{
+ /*
+ begin
+ c0:=bc; c1:=ec; c2:=bc; c3:=ec;
+ for c:=bc to ec do if char_wd[c]>0 then
+ begin
+ temp_width:=memory[char_wd[c]];
+ if design_units<>unity then
+ temp_width:=round((temp_width/design_units)*1048576.0);
+ temp_width:=temp_width + (c+4)*@'20000000; {this should be positive}
+ c0:=(c0+c0+temp_width) mod 255;
+ c1:=(c1+c1+temp_width) mod 253;
+ c2:=(c2+c2+temp_width) mod 251;
+ c3:=(c3+c3+temp_width) mod 247;
+ end;
+ header_bytes[check_sum_loc]:=c0;
+ header_bytes[check_sum_loc+1]:=c1;
+ header_bytes[check_sum_loc+2]:=c2;
+ header_bytes[check_sum_loc+3]:=c3;
+ end
+ */
+}
+
+#define add_tfmwidth(v) (add_tfmtable(widthtab, &numwidth, v, MAXWIDTHTAB,\
+ "TFM width"))
+#define add_tfmheight(v) (add_tfmtable(heighttab, &numheight, v, MAXHEIGHTTAB,\
+ "TFM height"))
+#define add_tfmdepth(v) (add_tfmtable(depthtab, &numdepth, v, MAXDEPTHTAB,\
+ "TFM depth"))
+#define add_tfmitalic(v) (add_tfmtable(italictab, &numitalic, v, MAXITALICTAB,\
+ "Italic correction"))
+byte
+add_tfmtable(table, count, value, maxv, name)
+ integer *table, *count, value, maxv;
+ char *name;
+{
+ integer i;
+ for (i = 0; i < *count; i++) /* search for value in tfm table */
+ if (table[i] == value) return (byte)i;
+ if (*count >= maxv) {
+ fprintf(stderr, "Too many values in %s table!\n", name) ;
+ jumpout();
+ }
+ if (!fixrange(value)) {
+ fprintf(stderr, " %s %f for char %d out of range!\n",
+ name, unfixword(value), car);
+ jumpout();
+ }
+ table[*count] = value ;
+ return (*count)++ ;
+}
+
+add_suffix(name, suffix)
+ char *name, *suffix ;
+{
+ int haveext = 0;
+ if (name && strcmp(name, "-")) {
+ while (*name) {
+ if (*name == '/') haveext = 0 ;
+ else if (*name == '.') haveext = 1 ;
+ name++ ;
+ }
+ if (!haveext) {
+ *name++ = '.';
+ strcpy(name,suffix) ;
+ }
+ }
+}
+
+initialize()
+{
+ integer i ;
+ fprintf(stderr, "This is PBMtoPK, C Version 2.3\n") ;
+ for (i = 0 ; i <= 31 ; i ++) xchr[i] = '?' ;
+ xchr[32] = ' ' ;
+ xchr[33] = '!' ;
+ xchr[34] = '"' ;
+ xchr[35] = '#' ;
+ xchr[36] = '$' ;
+ xchr[37] = '%' ;
+ xchr[38] = '&' ;
+ xchr[39] = '\'' ;
+ xchr[40] = '(' ;
+ xchr[41] = ')' ;
+ xchr[42] = '*' ;
+ xchr[43] = '+' ;
+ xchr[44] = ',' ;
+ xchr[45] = '-' ;
+ xchr[46] = '.' ;
+ xchr[47] = '/' ;
+ xchr[48] = '0' ;
+ xchr[49] = '1' ;
+ xchr[50] = '2' ;
+ xchr[51] = '3' ;
+ xchr[52] = '4' ;
+ xchr[53] = '5' ;
+ xchr[54] = '6' ;
+ xchr[55] = '7' ;
+ xchr[56] = '8' ;
+ xchr[57] = '9' ;
+ xchr[58] = ':' ;
+ xchr[59] = ';' ;
+ xchr[60] = '<' ;
+ xchr[61] = '=' ;
+ xchr[62] = '>' ;
+ xchr[63] = '?' ;
+ xchr[64] = '@' ;
+ xchr[65] = 'A' ;
+ xchr[66] = 'B' ;
+ xchr[67] = 'C' ;
+ xchr[68] = 'D' ;
+ xchr[69] = 'E' ;
+ xchr[70] = 'F' ;
+ xchr[71] = 'G' ;
+ xchr[72] = 'H' ;
+ xchr[73] = 'I' ;
+ xchr[74] = 'J' ;
+ xchr[75] = 'K' ;
+ xchr[76] = 'L' ;
+ xchr[77] = 'M' ;
+ xchr[78] = 'N' ;
+ xchr[79] = 'O' ;
+ xchr[80] = 'P' ;
+ xchr[81] = 'Q' ;
+ xchr[82] = 'R' ;
+ xchr[83] = 'S' ;
+ xchr[84] = 'T' ;
+ xchr[85] = 'U' ;
+ xchr[86] = 'V' ;
+ xchr[87] = 'W' ;
+ xchr[88] = 'X' ;
+ xchr[89] = 'Y' ;
+ xchr[90] = 'Z' ;
+ xchr[91] = '[' ;
+ xchr[92] = '\\' ;
+ xchr[93] = ']' ;
+ xchr[94] = '^' ;
+ xchr[95] = '_' ;
+ xchr[96] = '`' ;
+ xchr[97] = 'a' ;
+ xchr[98] = 'b' ;
+ xchr[99] = 'c' ;
+ xchr[100] = 'd' ;
+ xchr[101] = 'e' ;
+ xchr[102] = 'f' ;
+ xchr[103] = 'g' ;
+ xchr[104] = 'h' ;
+ xchr[105] = 'i' ;
+ xchr[106] = 'j' ;
+ xchr[107] = 'k' ;
+ xchr[108] = 'l' ;
+ xchr[109] = 'm' ;
+ xchr[110] = 'n' ;
+ xchr[111] = 'o' ;
+ xchr[112] = 'p' ;
+ xchr[113] = 'q' ;
+ xchr[114] = 'r' ;
+ xchr[115] = 's' ;
+ xchr[116] = 't' ;
+ xchr[117] = 'u' ;
+ xchr[118] = 'v' ;
+ xchr[119] = 'w' ;
+ xchr[120] = 'x' ;
+ xchr[121] = 'y' ;
+ xchr[122] = 'z' ;
+ xchr[123] = '{' ;
+ xchr[124] = '|' ;
+ xchr[125] = '}' ;
+ xchr[126] = '~' ;
+ for (i = 127 ; i <= 255 ; i ++) xchr[i] = '?' ;
+ for (i = 0 ; i <= 127 ; i ++) xord[chr(i)] = 32 ;
+ for (i = 32 ; i <= 126 ; i ++) xord[xchr[i]] = i ;
+ for (i = 0 ; i < 32 ; i++) power[i] = 1 << i ;
+ for (i = 0; i < MAXPKCHAR; i++) {
+ filename[i] = NULL;
+ charflags[i] = 0;
+ }
+ pkloc = 0 ;
+ designsize = fixword(1.0) ;
+ numparam = 0;
+ widthtab[0] = heighttab[0] = depthtab[0] = italictab[0] = 0 ;
+ numwidth = numheight = numdepth = numitalic = 1;
+ smallestch = MAXPKCHAR ;
+ largestch = -1 ;
+ emwidth = 0 ;
+}
+
+jumpout()
+{
+ exit(1) ;
+}
+
+pkbyte(b)
+ integer b ;
+{
+ if (b < 0) b = b + 256 ;
+ putc(b, pkfile) ;
+ pkloc++ ;
+}
+
+pkhalfword(a)
+ integer a ;
+{
+ if (a < 0) a = a + 65536 ;
+ pkbyte(a >> 8) ;
+ pkbyte(a & 255) ;
+}
+
+pkthreebytes(a)
+ integer a ;
+{
+ pkbyte((a>>16) & 255) ;
+ pkbyte((a>>8) & 255) ;
+ pkbyte(a & 255) ;
+}
+
+pkword(a)
+ integer a ;
+{
+ pkbyte((a>>24) & 255) ;
+ pkbyte((a>>16) & 255) ;
+ pkbyte((a>>8) & 255) ;
+ pkbyte(a & 255) ;
+}
+
+pknyb(a)
+ integer a ;
+{
+ if (bitweight == 16) {
+ outputbyte = (a<<4) ;
+ bitweight = 1 ;
+ } else {
+ pkbyte(outputbyte + a) ;
+ bitweight = 16 ;
+ }
+}
+
+writepreamble()
+{
+ integer i ;
+ char *comment = "PBMtoPK 2.3 output" ;
+
+ pkbyte(247) ;
+ pkbyte(89) ;
+ pkbyte(strlen(comment)) ;
+ for (i = 0 ; i < strlen(comment); i++) pkbyte(xord[comment[i]]) ;
+ pkword(designsize) ;
+ pkword(checksum) ; /* checksum; calculate if possible */
+ pkword(hppp) ;
+ pkword(hppp) ;
+}
+
+writepostamble()
+{
+ pkbyte(245) ;
+ while ((pkloc % 4 != 0)) pkbyte(246) ;
+ fprintf(stderr, "%d bytes written to packed file.\n", pkloc) ;
+}
+
+tfmbyte(b)
+ integer b ;
+{
+ if (b < 0) b = b + 256 ;
+ putc(b, tfmfile) ;
+}
+
+tfmhalfword(a)
+ integer a ;
+{
+ if (a < 0) a = a + 65536 ;
+ tfmbyte(a >> 8) ;
+ tfmbyte(a & 255) ;
+}
+
+tfmword(a)
+ integer a ;
+{
+ tfmbyte((a>>24) & 255) ;
+ tfmbyte((a>>16) & 255) ;
+ tfmbyte((a>>8) & 255) ;
+ tfmbyte(a & 255) ;
+}
+
+writetfmfile()
+{
+ integer totallength ;
+ integer headersize = 17;
+ integer i ;
+
+ if (largestch - smallestch < 0) {
+ largestch = 0;
+ smallestch = 1;
+ }
+ if (numparam < 7) /* set default parameters */
+ switch (numparam) {
+ case 0: /* slant */
+ parameters[numparam++] = 0 ;
+ case 1: /* space */
+ parameters[numparam++] = fixword(designunits(emwidth/3.0));
+ case 2: /* space_stretch */
+ parameters[numparam++] = fixword(unfixword(parameters[1])/2.0) ;
+ case 3: /* space_shrink */
+ parameters[numparam++] = fixword(unfixword(parameters[1])/3.0) ;
+ case 4: /* x_height */
+ parameters[numparam++] = fixword(0.45);
+ case 5: /* quad */
+ parameters[numparam++] = fixword(designunits(emwidth)) ;
+ case 6: /* extra_space */
+ parameters[numparam++] = fixword(unfixword(parameters[1])/3.0) ;
+ }
+ totallength = 6 + headersize + (largestch+1-smallestch) +
+ numwidth + numheight + numdepth + numitalic + numparam ;
+ /* lengths */
+ tfmhalfword(totallength) ;
+ tfmhalfword(headersize) ;
+ tfmhalfword(smallestch) ;
+ tfmhalfword(largestch) ;
+ tfmhalfword(numwidth) ;
+ tfmhalfword(numheight) ;
+ tfmhalfword(numdepth) ;
+ tfmhalfword(numitalic) ;
+ tfmhalfword(0) ; /* lig/kern table */
+ tfmhalfword(0) ; /* kern table */
+ tfmhalfword(0) ; /* extensible char table */
+ tfmhalfword(numparam) ;
+ /* header */
+ tfmword(checksum) ;
+ tfmword(designsize) ;
+ if (strlen(codingscheme) > 39) tfmbyte(39) ;
+ else tfmbyte(strlen(codingscheme)) ;
+ for (i = 0; i < 39; i++)
+ if (*codingscheme) tfmbyte(xord[*codingscheme++]) ;
+ else tfmbyte(0) ;
+ if (strlen(familyname) > 19) tfmbyte(19) ;
+ else tfmbyte(strlen(familyname)) ;
+ for (i = 0; i < 19; i++)
+ if (*familyname) tfmbyte(xord[*familyname++]) ;
+ else tfmbyte(0) ;
+ /* char_info */
+ for (car = smallestch; car <= largestch; car++)
+ if (filename[car]) {
+ tfmbyte(tfmindex[car]) ;
+ tfmbyte((hgtindex[car]<<4) + depindex[car]) ;
+ tfmbyte(italindex[car]<<2) ;
+ tfmbyte(0) ;
+ } else tfmword(0) ;
+ /* width */
+ for (i = 0; i < numwidth; i++) tfmword(widthtab[i]) ;
+ /* height */
+ for (i = 0; i < numheight; i++) tfmword(heighttab[i]) ;
+ /* depth */
+ for (i = 0; i < numdepth; i++) tfmword(depthtab[i]) ;
+ /* italic */
+ for (i = 0; i < numitalic; i++) tfmword(italictab[i]) ;
+ /* no lig_kern, kern, or exten */
+ /* param */
+ for (i = 0; i < numparam; i++)
+ if (i && (!fixrange(parameters[i]))) {
+ fprintf(stderr, " Parameter %d out of range (-p)!\n", i);
+ jumpout();
+ }
+ else tfmword(parameters[i]) ;
+ fprintf(stderr, "%d bytes written to tfm file.\n", totallength*4) ;
+}
+
+readcharacter()
+{
+ FILE *fp;
+
+ if (!strcmp(filename[car], "-")) fp = stdin;
+ else if ((fp = fopen(filename[car], "r")) == NULL) {
+ fprintf(stderr, " Can't open pbm file %s!\n", filename[car]);
+ jumpout();
+ }
+ bitmap = pbm_readpbm(fp, &width, &height) ;
+ if (fp != stdin) fclose(fp) ;
+
+ if ((charflags[car] & HORZESC) == 0) horzesc[car] = width ;
+ if ((charflags[car] & VERTESC) == 0) vertesc[car] = 0;
+ if ((charflags[car] & XOFFSET) == 0) xoffset[car] = 0;
+ if ((charflags[car] & YOFFSET) == 0) yoffset[car] = height-1;
+ if ((charflags[car] & TFMWIDTH) == 0)
+ tfmindex[car] = add_tfmwidth(fixword(designunits(width)));
+ if ((charflags[car] & TFMHEIGHT) == 0)
+ hgtindex[car] = add_tfmheight(fixword(designunits(yoffset[car]+1)));
+ if ((charflags[car] & TFMDEPTH) == 0)
+ depindex[car] = add_tfmdepth(fixword(designunits(height-1-yoffset[car])));
+ if ((charflags[car] & TFMITALIC) == 0) italindex[car] = 0;
+
+ if (car < smallestch) smallestch = car;
+ if (car > largestch) largestch = car;
+ if (width > emwidth) emwidth = width ;
+}
+
+int
+equal(row1, row2)
+ bit *row1, *row2 ;
+{
+ integer i ;
+
+ for (i = 0; i < width; i++)
+ if (row1[i] != row2[i]) return (0) ;
+ return(1) ;
+}
+
+shipcharacter()
+{
+ integer compsize ;
+ integer i, j, k ;
+ bit *zerorow, *onesrow ;
+ integer *repeatptr, *bitcounts ;
+ integer count ;
+ integer test ;
+ integer curptr, rowptr ;
+ integer bitval ;
+ integer repeatflag ;
+ integer colptr ;
+ integer currepeat ;
+ integer dynf ;
+ integer deriv[14] ;
+ integer bcompsize ;
+ boolean firston ;
+ integer flagbyte ;
+ boolean state ;
+ boolean on ;
+ integer hbit ;
+ integer pbit ;
+ boolean ron, son ;
+ integer rcount, scount ;
+ integer ri, si ;
+ integer max2 ;
+ integer predpkloc ;
+ integer buff ;
+
+ integer tfwid = widthtab[tfmindex[car]] ;
+ integer hesc = horzesc[car] ;
+ integer vesc = vertesc[car] ;
+ integer xoff = xoffset[car] ;
+ integer yoff = yoffset[car] ;
+
+ zerorow = pbm_allocrow(width) ;
+ onesrow = pbm_allocrow(width) ;
+ repeatptr =
+ (integer *)malloc((unsigned int)((height+1)*sizeof(integer))) ;
+ bitcounts =
+ (integer *)malloc((unsigned int)((height*width)*sizeof(integer))) ;
+ if (repeatptr == NULL || bitcounts == NULL) {
+ fprintf(stderr, " Out of memory while allocating bit counts!\n");
+ jumpout() ;
+ }
+ for (i = 0 ; i < width ; i++) {
+ zerorow[i] = PBM_WHITE ;
+ onesrow[i] = PBM_BLACK ;
+ }
+ for (i=0; i < height; i++) {
+ if (equal(bitmap[i], zerorow))
+ repeatptr[i] = 0 ;
+ else if (equal(bitmap[i], onesrow))
+ repeatptr[i] = 0 ;
+ else if (i + 1 < height && equal(bitmap[i],bitmap[i+1]))
+ repeatptr[i] = 1 ;
+ else
+ repeatptr[i] = 0 ;
+ }
+ i = 0 ;
+ while (i < height) {
+ k = i ;
+ while (repeatptr[k] == 1) k++ ;
+ repeatptr[i] = k - i ;
+ i = k + 1 ;
+ }
+ repeatptr[i] = 0 ;
+ colptr = width - 1 ;
+ repeatflag = currepeat = curptr = count = rowptr = 0 ;
+ test = PBM_WHITE ;
+ do {
+ colptr++ ;
+ if (colptr == width) {
+ colptr = 0 ;
+ rowptr = currepeat ;
+ if (repeatptr[currepeat] > 0) {
+ repeatflag = repeatptr[currepeat] ;
+ currepeat += repeatflag ;
+ rowptr += repeatflag ;
+ }
+ currepeat++ ;
+ }
+ if (rowptr >= height) bitval = -1 ;
+ else bitval = bitmap[rowptr][colptr] ;
+ if (bitval == test) count++ ;
+ else {
+ bitcounts[curptr++] = count ;
+ if (curptr+3 >= height*width) {
+ fprintf(stderr, " Out of memory while saving character counts!\n");
+ jumpout() ;
+ }
+ count = 1 ;
+ test = bitval ;
+ if (repeatflag > 0) {
+ bitcounts[curptr++] = -repeatflag ;
+ repeatflag = 0 ;
+ }
+ }
+ } while (test != -1) ;
+ bitcounts[curptr] = 0 ;
+ bitcounts[curptr + 1] = 0 ;
+ for (i = 1 ; i <= 13 ; i ++) deriv[i] = 0 ;
+ i = firston = (bitcounts[0] == 0) ;
+ compsize = 0 ;
+ while (bitcounts[i] != 0) {
+ j = bitcounts[i] ;
+ if (j == -1) compsize++ ;
+ else {
+ if (j < 0) {
+ compsize++ ;
+ j = -j ;
+ }
+ if (j < 209) compsize += 2 ;
+ else {
+ k = j - 193 ;
+ while (k >= 16) {
+ k >>= 4 ;
+ compsize += 2 ;
+ }
+ compsize++ ;
+ }
+ if (j < 14) (deriv[j])-- ;
+ else if (j < 209) (deriv[(223 - j) / 15])++ ;
+ else {
+ k = 16 ;
+ while (((k<<4) < j + 3)) k <<= 4 ;
+ if (j - k <= 192)
+ deriv[(207 - j + k) / 15] += 2 ;
+ }
+ }
+ i++ ;
+ }
+ bcompsize = compsize ;
+ dynf = 0 ;
+ for (i = 1 ; i <= 13 ; i ++) {
+ compsize += deriv[i] ;
+ if (compsize <= bcompsize) {
+ bcompsize = compsize ;
+ dynf = i ;
+ }
+ }
+ compsize = ((bcompsize + 1)>>1) ;
+ if ((compsize > ((height*width+7)>>3)) || (height*width == 0)) {
+ compsize = ((height*width+7)>>3) ;
+ dynf = 14 ;
+ }
+ flagbyte = (dynf<<4) ;
+ if (firston) flagbyte |= 8 ;
+ if ((tfwid > 16777215) || (tfwid < 0) || (hesc < 0) || (vesc != 0) ||
+ (compsize > 196579) || (width > 65535) || (height > 65535) ||
+ (xoff > 32767) || (yoff > 32767) || (xoff < -32768) || (yoff < -32768)) {
+ flagbyte |= 7 ;
+ pkbyte(flagbyte) ;
+ compsize += 28 ;
+ pkword(compsize) ;
+ pkword(car) ;
+ predpkloc = pkloc + compsize ;
+ pkword(tfwid) ;
+ pkword(hesc<<16) ;
+ pkword(vesc<<16) ;
+ pkword(width) ;
+ pkword(height) ;
+ pkword(xoff) ;
+ pkword(yoff) ;
+ } else if ((hesc > 255) || (width > 255) || (height > 255) ||
+ (xoff > 127) || (yoff > 127) || (xoff < -128) ||
+ (yoff < -128) || (compsize > 1016)) {
+ compsize += 13 ;
+ flagbyte += (compsize>>16) + 4 ;
+ pkbyte(flagbyte) ;
+ pkhalfword(compsize & 65535) ;
+ pkbyte(car) ;
+ predpkloc = pkloc + compsize ;
+ pkthreebytes(tfwid) ;
+ pkhalfword(hesc) ;
+ pkhalfword(width) ;
+ pkhalfword(height) ;
+ pkhalfword(xoff) ;
+ pkhalfword(yoff) ;
+ } else {
+ compsize += 8 ;
+ flagbyte = flagbyte + (compsize>>8) ;
+ pkbyte(flagbyte) ;
+ pkbyte(compsize & 255) ;
+ pkbyte(car) ;
+ predpkloc = pkloc + compsize ;
+ pkthreebytes(tfwid) ;
+ pkbyte(hesc) ;
+ pkbyte(width) ;
+ pkbyte(height) ;
+ pkbyte(xoff) ;
+ pkbyte(yoff) ;
+ }
+ if (dynf != 14) {
+ bitweight = 16 ;
+ max2 = 208 - 15 * dynf ;
+ i = firston ;
+ while (bitcounts[i] != 0) {
+ j = bitcounts[i] ;
+ if (j == - 1) pknyb(15) ;
+ else {
+ if (j < 0) {
+ pknyb(14) ;
+ j = -j ;
+ }
+ if (j <= dynf) pknyb(j) ;
+ else if (j <= max2) {
+ j -= dynf + 1 ;
+ pknyb((j >> 4) + dynf + 1) ;
+ pknyb((j & 15)) ;
+ } else {
+ j -= max2 - 15 ;
+ k = 16 ;
+ while (k <= j) {
+ k <<= 4 ;
+ pknyb(0) ;
+ }
+ while (k > 1) {
+ k >>= 4 ;
+ pknyb(j / k) ;
+ j = j % k ;
+ }
+ }
+ }
+ i++ ;
+ }
+ if (bitweight != 16) pkbyte(outputbyte) ;
+ } else {
+ buff = 0 ;
+ pbit = 8 ;
+ i = firston ;
+ hbit = width ;
+ on = ! firston ;
+ state = false ;
+ count = repeatflag = 0 ;
+ while ((bitcounts[i] != 0) || state || (count > 0)) {
+ if (state) {
+ count = rcount ;
+ i = ri ;
+ on = ron ;
+ repeatflag-- ;
+ } else {
+ rcount = count ;
+ ri = i ;
+ ron = on ;
+ }
+ do {
+ if (count == 0) {
+ if (bitcounts[i] < 0) {
+ if (! state) repeatflag = -bitcounts[i] ;
+ i++ ;
+ }
+ count = bitcounts[i] ;
+ i++ ;
+ on = !on ;
+ }
+ if ((count >= pbit) && (pbit < hbit)) {
+ if (on) buff += power[pbit] - 1 ;
+ pkbyte(buff) ;
+ buff = 0 ;
+ hbit -= pbit ;
+ count -= pbit ;
+ pbit = 8 ;
+ } else if ((count < pbit) && (count < hbit)) {
+ if (on) buff += power[pbit] - power[pbit - count] ;
+ pbit -= count ;
+ hbit -= count ;
+ count = 0 ;
+ } else {
+ if (on) buff += power[pbit] - power[pbit - hbit] ;
+ count -= hbit ;
+ pbit -= hbit ;
+ hbit = width ;
+ if (pbit == 0) {
+ pkbyte(buff) ;
+ buff = 0 ;
+ pbit = 8 ;
+ }
+ }
+ } while (hbit != width) ;
+ if (state && (repeatflag == 0)) {
+ count = scount ;
+ i = si ;
+ on = son ;
+ state = false ;
+ } else if (! state && (repeatflag > 0)) {
+ scount = count ;
+ si = i ;
+ son = on ;
+ state = true ;
+ }
+ }
+ if (pbit != 8) pkbyte(buff) ;
+ }
+ if (predpkloc != pkloc) {
+ fprintf(stderr, " Bad predicted character length: character %d!\n", car);
+ jumpout() ;
+ }
+ pbm_freerow(zerorow);
+ pbm_freerow(onesrow);
+ free((char *)repeatptr);
+ free((char *)bitcounts);
+}
+
+usage()
+{
+ fprintf(stderr, " Usage: pbmtopk pkfile[.pk] tfmfile[.tfm] dpi\n") ;
+ fprintf(stderr, " [-s designsize] [-p num param...]\n");
+ fprintf(stderr, " [-C codingscheme ] [-F family]\n");
+ fprintf(stderr, " [-c num | <char>]...\n");
+ fprintf(stderr, " <char> is: [-W tfmwidth] [-H tfmheight] [-D tfmdepth]\n");
+ fprintf(stderr, " [-I ital_corr] [-h horiz] [-v vert]\n") ;
+ fprintf(stderr, " [-x xoffset] [-y yoffset] file\n") ;
+ fprintf(stderr, " or: -f optfile\n") ;
+ jumpout() ;
+}
+
+checkchar()
+{
+ if (car < 0 || car >= MAXPKCHAR) {
+ fprintf(stderr, " Character must be in range 0 to %d (-c)!\n",
+ MAXPKCHAR-1) ;
+ jumpout() ;
+ }
+}
+
+optionfile(name)
+ char *name ;
+{
+ FILE *fp ;
+ char buffer[MAXOPTLINE] ;
+
+ if (!strcmp(name, "-")) fp = stdin ;
+ else if ((fp = fopen(name, "r")) == NULL) {
+ fprintf(stderr, " Can't open option file %s!\n", name) ;
+ jumpout() ;
+ }
+ while (!feof(fp)) {
+ char *here = buffer;
+
+ if (fgets(buffer, MAXOPTLINE, fp) == NULL) break ;
+ while (isspace(*here)) here++ ;
+ if (*here && *here == '=') {
+ if (sscanf(here+1, "%d", &car) != 1) {
+ fprintf(stderr, "Bad option file line %s!\n", buffer) ;
+ jumpout() ;
+ }
+ } else if (*here && *here != '%' && *here != '#') {
+ char str[NAMELENGTH] ;
+ integer i, n;
+
+ checkchar() ;
+ if (sscanf(here, "%s%n", str, &n) != 1) {
+ fprintf(stderr, "Bad option file line %s!\n", buffer) ;
+ jumpout() ;
+ }
+ filename[car] =
+ (char *)malloc((unsigned int)(sizeof(char)*(strlen(str)+1))) ;
+ strcpy(filename[car], str) ;
+ for (i = 1; i < 256; i<<=1) {
+ here += n;
+ if (sscanf(here, "%s%n", str, &n) != 1) break ;
+ if (strcmp(str, "*")) {
+ charflags[car] |= i ;
+ switch (i) {
+ case XOFFSET:
+ xoffset[car] = atoi(str) ;
+ break ;
+ case YOFFSET:
+ yoffset[car] = atoi(str) ;
+ break ;
+ case HORZESC:
+ horzesc[car] = atoi(str) ;
+ break ;
+ case VERTESC:
+ vertesc[car] = atoi(str) ;
+ break ;
+ case TFMWIDTH:
+ tfmindex[car] = add_tfmwidth(fixword(atof(str))) ;
+ break ;
+ case TFMHEIGHT:
+ hgtindex[car] = add_tfmheight(fixword(atof(str))) ;
+ break ;
+ case TFMDEPTH:
+ depindex[car] = add_tfmdepth(fixword(atof(str))) ;
+ break ;
+ case TFMITALIC:
+ italindex[car] = add_tfmitalic(fixword(atof(str))) ;
+ break ;
+ }
+ }
+ }
+ car++ ;
+ }
+ }
+ if (fp != stdin) fclose(fp) ;
+}
+
+dialog(gargc, gargv)
+ int gargc ;
+ char **gargv ;
+{
+ integer i, hesc, vesc, xoff, yoff, tfwid, tfdep, tfhgt, tfital ;
+ byte flags ;
+
+ if (--gargc < 1) usage() ;
+ strcpy(pkname, *++gargv) ;
+ add_suffix(pkname, "pk") ;
+
+ if (--gargc < 1) usage() ;
+ strcpy(tfmname, *++gargv) ;
+ add_suffix(tfmname, "tfm") ;
+
+ if (--gargc < 1) usage() ;
+ resolution = atoi(*++gargv) ;
+ if (resolution < 1 || resolution > 32767) {
+ fprintf(stderr, " Unlikely resolution %d dpi!\n", resolution);
+ jumpout();
+ }
+
+ car = flags = hesc = vesc = xoff = yoff = tfwid = 0;
+ while (++gargv, --gargc) {
+ if (gargv[0][0] == '-' && gargv[0][1]) {
+ char c, *p;
+ c = gargv[0][1] ;
+ if (gargv[0][2]) p = *gargv + 2 ;
+ else if (++gargv, --gargc) p = *gargv ;
+ else usage() ;
+ switch (c) {
+ case 'C':
+ codingscheme = p;
+ break ;
+ case 'F':
+ familyname = p;
+ break ;
+ case 'c':
+ car = atoi(p) ;
+ break ;
+ case 's':
+ designsize = fixword(atof(p));
+ if (designsize < 1048576) {
+ fprintf(stderr, " Design size %f out of range!\n",
+ unfixword(designsize));
+ jumpout() ;
+ }
+ case 'h':
+ hesc = atoi(p) ;
+ flags |= HORZESC ;
+ break ;
+ case 'v':
+ vesc = atoi(p) ;
+ flags |= VERTESC ;
+ break ;
+ case 'x':
+ xoff = atoi(p) ;
+ flags |= XOFFSET ;
+ break ;
+ case 'y':
+ yoff = atoi(p) ;
+ flags |= YOFFSET ;
+ break ;
+ case 'W':
+ tfwid = fixword(atof(p)) ;
+ flags |= TFMWIDTH ;
+ break ;
+ case 'H':
+ tfhgt = fixword(atof(p)) ;
+ flags |= TFMHEIGHT ;
+ break ;
+ case 'D':
+ tfdep = fixword(atof(p)) ;
+ flags |= TFMDEPTH ;
+ break ;
+ case 'I':
+ tfital = fixword(atof(p)) ;
+ flags |= TFMITALIC ;
+ break ;
+ case 'f':
+ optionfile(p) ;
+ break ;
+ case 'p':
+ numparam = atoi(p);
+ if (numparam < 1 || numparam > 30) {
+ fprintf(stderr, " Parameter count %d out of range!\n", numparam);
+ jumpout();
+ }
+ for (i=0; i<numparam; i++)
+ if (++gargv,--gargc) parameters[i] = fixword(atof(*gargv)) ;
+ else {
+ fprintf(stderr, " Not enough parameters (-p)!\n");
+ jumpout() ;
+ }
+ break ;
+ default:
+ usage() ;
+ }
+ } else {
+ checkchar() ;
+ if (flags & TFMWIDTH)
+ tfmindex[car] = add_tfmwidth(tfwid);
+ if (flags & TFMDEPTH)
+ depindex[car] = add_tfmdepth(tfdep);
+ if (flags & TFMHEIGHT)
+ hgtindex[car] = add_tfmheight(tfhgt);
+ if (flags & TFMITALIC)
+ italindex[car] = add_tfmitalic(tfital);
+ horzesc[car] = hesc ;
+ vertesc[car] = vesc ;
+ xoffset[car] = xoff ;
+ yoffset[car] = yoff ;
+ filename[car] = *gargv ;
+ charflags[car] = flags ;
+ car++ ;
+ flags = 0;
+ }
+ }
+}
+
+main(argc, argv)
+ int argc ;
+ char *argv[] ;
+{
+ initialize() ;
+ dialog(argc, argv) ;
+ hppp = round((resolution<<16) / 72.27) ;
+ add_suffix(pkname, "pk") ;
+ add_suffix(tfmname, "tfm") ;
+ if (!strcmp(pkname, "-")) pkfile = stdout;
+ else if ((pkfile = fopen(pkname, "w")) == NULL) {
+ fprintf(stderr, " Can't open PK file %s!\n", pkname);
+ jumpout() ;
+ }
+ if (!strcmp(tfmname, "-")) tfmfile = stdout ;
+ else if ((tfmfile = fopen(tfmname, "w")) == NULL) {
+ fprintf(stderr, " Can't open TFM file %s!\n", tfmname);
+ jumpout();
+ }
+ writepreamble() ;
+ for (car = 0 ; car < MAXPKCHAR ; car++)
+ if (filename[car]) {
+ readcharacter() ;
+ shipcharacter() ;
+ }
+ writepostamble() ;
+ writetfmfile() ;
+ if (pkfile != stdout) fclose(pkfile) ;
+ if (tfmfile != stdout) fclose(tfmfile) ;
+ exit(0);
+}
diff --git a/graphics/pbmtopk/pbmtopk/pktopbm.1 b/graphics/pbmtopk/pbmtopk/pktopbm.1
new file mode 100644
index 0000000000..ff0329d55f
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/pktopbm.1
@@ -0,0 +1,17 @@
+.TH pktopbm 1 "6 August 1990"
+.SH NAME
+pktopbm - convert packed (PK) format font into portable bitmap(s)
+.SH SYNOPSIS
+pktopbm pkfile[.pk] [-c num] pbmfile ...
+.SH DESCRIPTION
+Reads a packed (PK) font file as input, and produces portable bitmaps as
+output. If the filename "-" is used for any
+of the filenames, the standard input stream (or standard output where
+appropriate) will be used.
+.SH OPTIONS
+.IP "-c num"
+Sets the character number of the next bitmap written to num.
+.SH "SEE ALSO"
+pbmtopk(1), pbm(5)
+.SH AUTHOR
+Adapted from Tom Rokicki's pxtopk by Angus Duggan <ajcd@uk.ac.ed.lfcs>.
diff --git a/graphics/pbmtopk/pbmtopk/pktopbm.c b/graphics/pbmtopk/pbmtopk/pktopbm.c
new file mode 100644
index 0000000000..d511a768c2
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/pktopbm.c
@@ -0,0 +1,381 @@
+/*
+ pktopbm, adapted from "pktopx in C by Tomas Rokicki" by AJCD 1/8/90
+
+ compile with: cc -lpbm -o pktopbm pktopbm.c
+ */
+
+#include <stdio.h>
+#include <pbm.h>
+
+#define NAMELENGTH 80
+#define MAXROWWIDTH 3200
+#define MAXPKCHAR 256
+
+#define round(a) ((int)(a+0.5))
+
+typedef int integer ;
+typedef unsigned char quarterword ;
+typedef char boolean ;
+typedef quarterword eightbits ;
+typedef FILE *bytefile ;
+
+bytefile pkfile ;
+char pkname[NAMELENGTH+1] ;
+integer pkloc ;
+integer i, j ;
+char *filename[MAXPKCHAR] ;
+bit **bitmap = NULL ;
+integer dynf ;
+eightbits inputbyte ;
+eightbits bitweight ;
+integer repeatcount ;
+integer flagbyte ;
+
+add_suffix(name, suffix)
+ char *name, *suffix ;
+{
+ int haveext = 0;
+ if (name) {
+ while (*name) {
+ if (*name == '/') haveext = 0 ;
+ else if (*name == '.') haveext = 1 ;
+ name++ ;
+ }
+ if (!haveext) {
+ *name++ = '.';
+ strcpy(name,suffix) ;
+ }
+ }
+}
+
+initialize()
+{
+ integer i ;
+
+ fprintf(stderr, "This is PKtoPBM, C Version 2.3\n") ;
+ for (i = 0 ; i < MAXPKCHAR ; i ++) filename[i] = NULL ;
+}
+
+jumpout()
+{
+ exit(1) ;
+}
+
+openpkfile()
+{
+ if ((pkfile = fopen(pkname, "r")) == NULL) {
+ fprintf(stderr, " Can't open pk file %s!\n", pkname) ;
+ }
+ pkloc = 0 ;
+}
+
+eightbits pkbyte()
+{
+ pkloc++ ;
+ return(getc(pkfile)) ;
+}
+
+integer get16()
+{
+ integer a = pkbyte() ;
+ return((a<<8) + pkbyte()) ;
+}
+
+integer get32()
+{
+ integer a = get16() ;
+ if (a > 32767) a -= 65536 ;
+ return((a<<16) + get16()) ;
+}
+
+integer getnyb()
+{
+ eightbits temp ;
+ if (bitweight == 0) {
+ inputbyte = pkbyte() ;
+ bitweight = 16 ;
+ }
+ temp = inputbyte / bitweight ;
+ inputbyte -= temp * bitweight ;
+ bitweight >>= 4 ;
+ return(temp) ;
+}
+
+boolean getbit()
+{
+ boolean temp ;
+ bitweight >>= 1 ;
+ if (bitweight == 0) {
+ inputbyte = pkbyte() ;
+ bitweight = 128 ;
+ }
+ temp = (inputbyte >= bitweight) ;
+ if (temp) inputbyte -= bitweight ;
+ return(temp) ;
+}
+
+integer pkpackednum()
+{
+ integer i, j ;
+ i = getnyb() ;
+ if (i == 0) {
+ do {
+ j = getnyb() ;
+ i++ ;
+ } while (!(j != 0)) ;
+ while (i > 0) {
+ j = (j<<4) + getnyb() ;
+ i-- ;
+ }
+ return(j - 15 +((13 - dynf)<<4) + dynf) ;
+ } else if (i <= dynf) return(i) ;
+ else if (i < 14) return(((i - dynf - 1)<<4) + getnyb() + dynf + 1) ;
+ else {
+ if (i == 14) repeatcount = pkpackednum() ;
+ else repeatcount = 1 ;
+ return(pkpackednum()) ;
+ }
+}
+
+skipspecials()
+{
+ integer i, j, k ;
+ do {
+ flagbyte = pkbyte() ;
+ if (flagbyte >= 240)
+ switch(flagbyte) {
+ case 240:
+ case 241:
+ case 242:
+ case 243:
+ i = 0 ;
+ for (j = 240 ; j <= flagbyte ; j ++) i = (i<<8) + pkbyte() ;
+ for (j = 1 ; j <= i ; j ++) k = pkbyte() ;
+ break ;
+ case 244:
+ i = get32() ;
+ break ;
+ case 245:
+ break ;
+ case 246:
+ break ;
+ case 247:
+ case 248:
+ case 249:
+ case 250:
+ case 251:
+ case 252:
+ case 253:
+ case 254:
+ case 255:
+ fprintf(stderr, " Unexpected flag byte %d!\n", flagbyte) ;
+ jumpout() ;
+ }
+ } while (!((flagbyte < 240) || (flagbyte == 245))) ;
+}
+
+usage()
+{
+ fprintf(stderr, " Usage: pktopbm pkfile[.pk] [[-c num] pbmfile]...\n");
+ jumpout() ;
+}
+
+dialog(gargc, gargv)
+ int gargc ;
+ char **gargv ;
+{
+ integer car ;
+
+ if (--gargc < 1) usage() ;
+ strcpy(pkname, *++gargv) ;
+ add_suffix(pkname, "pk") ;
+ car = 0 ;
+ while (++gargv, --gargc) {
+ if (gargv[0][0] == '-' && gargv[0][1])
+ switch (gargv[0][1]) {
+ case 'c':
+ if (gargv[0][2]) car = atoi(*gargv+2) ;
+ else if (++gargv, --gargc) car = atoi(*gargv) ;
+ else usage() ;
+ break ;
+ default:
+ usage() ;
+ } else if (car < 0 || car >= MAXPKCHAR) {
+ fprintf(stderr, " Character must be in range 0 to %d (-c)!\n",
+ MAXPKCHAR-1) ;
+ jumpout() ;
+ } else filename[car++] = *gargv ;
+ }
+}
+
+main(argc, argv)
+ int argc ;
+ char *argv[] ;
+{
+ integer endofpacket ;
+ integer designsize ;
+ integer checksum ;
+ integer hppp, vppp ;
+ integer cheight, cwidth ;
+ integer horesc ;
+ integer packetlength ;
+ integer rowsleft ;
+ boolean turnon ;
+ integer hbit ;
+ integer count ;
+ integer rp ;
+ integer i, j, k ;
+ integer car ;
+ bit row[MAXROWWIDTH+1] ;
+
+ initialize() ;
+ dialog(argc, argv) ;
+ openpkfile() ;
+ if (pkbyte() != 247) {
+ fprintf(stderr, " Bad pk file (pre command missing)!\n") ;
+ jumpout() ;
+ }
+ if (pkbyte() != 89) {
+ fprintf(stderr, " Wrong version of packed file!\n") ;
+ jumpout() ;
+ }
+ j = pkbyte() ;
+ for (i = 1 ; i <= j ; i ++) k = pkbyte() ;
+ designsize = get32() ;
+ checksum = get32() ;
+ hppp = get32() ;
+ vppp = get32() ;
+ if (hppp != vppp) fprintf(stderr, " Warning: aspect ratio not 1:1!\n") ;
+ skipspecials() ;
+ while (flagbyte != 245) {
+ dynf = (flagbyte>>4) ;
+ flagbyte &= 15 ;
+ turnon = (flagbyte >= 8) ;
+ if (turnon) flagbyte &= 7 ;
+ if (flagbyte == 7) {
+ packetlength = get32() ;
+ car = get32() ;
+ endofpacket = packetlength + pkloc ;
+ if ((car >= MAXPKCHAR) || (car < 0)) goto lab9997 ;
+ i = get32() ; /* tfmwidth */
+ horesc = get32() ;
+ i = get32() ;
+ cwidth = get32() ;
+ cheight = get32() ;
+ if ((cwidth < 0) || (cheight < 0) || (cwidth > 65535) || (cheight > 65535)) goto lab9997 ;
+ i = get32() ;
+ j = get32() ;
+ } else if (flagbyte > 3) {
+ packetlength =((flagbyte - 4)<<16) + get16() ;
+ car = pkbyte() ;
+ endofpacket = packetlength + pkloc ;
+ if (car >= MAXPKCHAR) goto lab9997 ;
+ i = pkbyte() ; /* tfmwidth */
+ i = get16() ;
+ horesc = get16() ;
+ cwidth = get16() ;
+ cheight = get16() ;
+ i = get16() ;
+ j = get16() ;
+ } else {
+ packetlength = (flagbyte<<8) + pkbyte() ;
+ car = pkbyte() ;
+ endofpacket = packetlength + pkloc ;
+ if (car >= MAXPKCHAR) goto lab9997 ;
+ i = pkbyte() ; /* tfmwidth */
+ i = get16() ;
+ horesc = pkbyte() ;
+ cwidth = pkbyte() ;
+ cheight = pkbyte() ;
+ i = pkbyte() ;
+ j = pkbyte() ;
+ }
+ if (filename[car]) {
+ bitmap = pbm_allocarray(cwidth, cheight) ;
+ if (bitmap == NULL) {
+ fprintf(stderr, " Out of memory allocating bitmap!\n") ;
+ jumpout() ;
+ }
+ } else goto lab9997 ;
+ bitweight = 0 ;
+ if (dynf == 14) {
+ for (i = 0 ; i < cheight ; i ++)
+ for (j = 0 ; j < cwidth ; j ++) {
+ if (getbit())
+ bitmap[i][j] = PBM_BLACK ;
+ else
+ bitmap[i][j] = PBM_WHITE ;
+ }
+ } else {
+ rowsleft = cheight ;
+ hbit = cwidth ;
+ repeatcount = rp =0 ;
+ while (rowsleft > 0) {
+ count = pkpackednum() ;
+ while (count > 0) {
+ if (count < hbit) {
+ hbit -= count ;
+ while (count--) {
+ if (turnon)
+ row[rp++] = PBM_BLACK ;
+ else
+ row[rp++] = PBM_WHITE ;
+ }
+ } else {
+ count -= hbit ;
+ while (hbit--) {
+ if (turnon)
+ row[rp++] = PBM_BLACK ;
+ else
+ row[rp++] = PBM_WHITE ;
+ }
+ for (i = 0; i <= repeatcount; i++)
+ for (j = 0; j < cwidth; j++)
+ bitmap[i + cheight-rowsleft][j] = row[j] ;
+ rowsleft -= repeatcount + 1;
+ repeatcount = rp = 0 ;
+ hbit = cwidth ;
+ }
+ }
+ turnon = ! turnon ;
+ }
+ if ((rowsleft != 0) || (hbit != cwidth)) {
+ fprintf(stderr, " Bad pk file (more bits than required)!\n") ;
+ jumpout() ;
+ }
+ }
+ if (endofpacket != pkloc) {
+ fprintf(stderr, " Bad pk file (bad packet length)!\n") ;
+ jumpout() ;
+ }
+ /* output bitmap to file */
+ {
+ FILE *fp ;
+ if (!strcmp(filename[car], "-"))
+ fp = stdout ;
+ else {
+ if ((fp = fopen(filename[car], "w")) == NULL) {
+ fprintf(stderr, " Can't open file %s!\n", filename[car]) ;
+ jumpout() ;
+ }
+ }
+ filename[car] = NULL;
+ pbm_writepbm(fp, bitmap, cwidth, cheight, 0) ;
+ pbm_freearray(bitmap, cheight) ;
+ if (fp != stdout) (void)fclose(fp) ;
+ }
+ goto lab9998 ;
+ lab9997: while (pkloc != endofpacket) i = pkbyte() ;
+ if (car < 0 || car >= MAXPKCHAR)
+ fprintf(stderr, " Character %d out of range!\n", car) ;
+ lab9998: skipspecials() ;
+ }
+ while (! feof(pkfile)) i = pkbyte() ;
+ pkloc-- ;
+ for (car = 0; car < MAXPKCHAR; car++)
+ if (filename[car])
+ fprintf(stderr, " Warning: No character in position %d (file %s).\n",
+ car, filename[car]) ;
+ fprintf(stderr, "%d bytes read from packed file.\n", pkloc) ;
+ exit(0);
+}
diff --git a/graphics/pbmtopk/pbmtopk/sign.pbm b/graphics/pbmtopk/pbmtopk/sign.pbm
new file mode 100644
index 0000000000..3a8717968c
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/sign.pbm
@@ -0,0 +1,302 @@
+P1
+150 100
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000001111110000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000111111111000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000011110000011100000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000001111000000000110000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000011100000000000011000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000011000000000000001100000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000110000000000000001100000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000001100000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000011000000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000011000000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000110000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000110000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000001100000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000001100000000000000000000001100000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000011000000000000000000000001100000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000011000000000000000000000001100000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000110000000000000000000000001100000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000110000000000000000000000001100000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000001100000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000001100000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000001100000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000011000000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000011000000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000011000000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000110000000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000110000000000000000000000000011000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000001100000000000000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000001100000000000000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000001100000000000000000000000000110000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000011000000000000000000000000000110011000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000011000000000000000000000000000110011000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000011000000000000000000000000001100110000011000000111111100000000
+0000000111100000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000011000000000000000000000000001100110000011000011111111110000000
+0000011111111000000000000000000000000000000000000000011110000000000000
+0000000000
+0000000011000000000000000000000000001101110000011000111100000111000000
+0001110000011100000000000000000011000000000000000001111111000000000000
+0000000000
+0000000110000000000000000000000000011001100000111001110000000011100000
+0011100000001100000000000000000111100000000000000001100001000000000000
+0000000000
+0000000110000000000000000000000000011011100001101011000000000001110000
+0011000000000110000100000000001101100000000000000011000011000000000000
+0000000000
+0000000110000000000000000000000000011111100001101011000000000000110000
+0110000000000110000100000000001101100000000000000011000110000000000000
+0000000000
+0000000110000000000000000000000000000111000011001110000000000000110000
+0100000000000010001100000000011001100000000000000011111100000000000000
+0000000000
+0000000110000000000000000000000000001111000011001100000000000000110000
+1100000000000011001100000000011001100000000000000000111111000000000000
+0000000000
+0000000110000000000000000000000000001111000010001100000000000000110000
+1000000000000011001100000000111011000000000000000001110011110000000000
+0000000000
+0000000110000000000000000000000000011110000110011100000000000000110001
+1000000000000011001100000000110011000000000000000001100000111000000000
+0000000000
+0000000110000000000000000000000000110110000110011000000000000001100001
+1000000000000011011100000000110011000000000000000011000000001110000000
+0000000000
+0000000110000000000000000000000001101100000100011000000000000001100001
+1000000000000011011100000000110110000000000000000110000000000111000000
+0000000000
+0000000110000000000000000000000001101100001100111000000000000001100001
+1000000000000001011100000000111110000000000000001100000000000011000000
+0000000000
+0000000110000000000000000000000011001100001000111000000000000001100001
+1000000000000000111100000000111100000000000000011000000000000001100000
+0000000000
+0000000110000000000000000000000011001000011000110000000000000011000001
+1000000000000000111100000000111000000000000000110000000000000001100000
+0000000000
+0000000110000000000000000000000110011000011000110000000000000011000001
+1000000000000000101100000000110000000000000001100000000000000000110000
+0000000000
+0000000110000000000000000000001100011000011000110000000000000011000001
+1000000000000000101100000001110000000000000111000000000000000000110000
+0000000000
+0000000111000000000000000000011100111000110001110000000000000011000001
+1000000000000001001100000001111000000000011110001000000000000000110000
+0000000000
+0000000011000000000000000000111000111000100001100000000000000011000001
+1000000000000011001100000011011000000001111000001100000000000000110000
+0000000000
+0000000011000000000000000001110000011011000001100000000000000011000001
+1100000000000010001100000110011100001111100000000110000000000000110000
+0000000000
+0000000001100000000000000111100000011111000001100000000000000011000100
+1100000000000110001100001100001111111110000000000111000000000001100000
+0000000000
+0000000001110000000000001110000000001100000011100000000000000001001100
+0111000000001100001100011000000111110000000000000011100000000011100000
+0000000000
+0000000000111100000001111100000000000000000011100000000000000001111000
+0011100000111000011000110000000000000000000000000001111000000111000000
+0000000000
+0000000000001111111111100000000000000000000011100000000000000001110000
+0001111111110000011001100000000000000000000000000000011111111110000000
+0000000000
+0000000000000011111110000000000000000000000000000000000000000000000000
+0000011111000000011011000000000000000000000000000000000111111100000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000011110000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000011100000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000111000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000001111000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000011011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000110011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000001100011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000011000011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000001110000011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000011100000011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000111000000011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000011110000000011000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000011000000000111000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0001110000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0001100000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0011100000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0111000000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0110000000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+1100000000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+1100000000000000110000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000001
+1000000000000001100000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000001
+1000000000000001100000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000001100000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000011000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000011000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000011000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000110000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000110000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000000110000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000001100000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000001100000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000011
+0000000000011000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000001
+0000000000011000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000001
+1000000000110000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+1110000001100000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0111100111000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0001111110000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000011000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000000000
+0000000000
diff --git a/graphics/pbmtopk/pbmtopk/test.opt b/graphics/pbmtopk/pbmtopk/test.opt
new file mode 100644
index 0000000000..ce9828eea0
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/test.opt
@@ -0,0 +1,8 @@
+% pbmtopk option file for the 'test font.
+% invoke with: pbmtopk test.300pk test.tfm 300 -s 10 -f test.opt
+% reset character number to 65 ('A')
+= 65
+% character 'A': small 64x64 version of my face.
+face.pbm
+% character 'B': my name.
+sign.pbm * 57
diff --git a/graphics/pbmtopk/pbmtopk/test.tex b/graphics/pbmtopk/pbmtopk/test.tex
new file mode 100644
index 0000000000..40cbd3b2f0
--- /dev/null
+++ b/graphics/pbmtopk/pbmtopk/test.tex
@@ -0,0 +1,11 @@
+% test.tex
+% test file for simple font produced by pbmtopk.
+% AJCD 9 Aug 90
+
+\font\test=test
+
+This is a test of the font produced with pbmtopk; character A is {\test A},
+and character B is {\test B}.
+
+\vfil\eject
+\bye