From 6e80afc0d352d893cf66f956cb9a95d033ca4680 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 15 Dec 2014 14:15:50 +0000 Subject: ps2pk 1.7 git-svn-id: svn://tug.org/texlive/trunk@35828 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/ps2pk/pktest.c | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 Build/source/texk/ps2pk/pktest.c (limited to 'Build/source/texk/ps2pk/pktest.c') diff --git a/Build/source/texk/ps2pk/pktest.c b/Build/source/texk/ps2pk/pktest.c new file mode 100644 index 00000000000..c6fc7ea8b71 --- /dev/null +++ b/Build/source/texk/ps2pk/pktest.c @@ -0,0 +1,111 @@ +/* + * FILE: pktest.c + * + * PURPOSE: This program demonstrates how a PK file can be created from + * a single character bitmap. + * + * USAGE: pktest -c -W -H pkname < test.bm + * (test.bm contains the character from `The GFtoPK processor') + * + * VERSION: 1.7 (December 2014) + * + * AUTHOR: Piet Tutelaers (rcpt@urc.tue.nl) + */ + +int testing = 1; +#include +#include "basics.h" /* fatal() */ +#include "pkout.h" + +main(int argc, char *argv[]) +{ + int done, C = 0, W = 0, H = 0, c; + const char *myname; + char *pkname, comment[256]; + int next_pixel(); + + myname = argv[0]; + while (--argc > 0 && (*++argv)[0] == '-') { + done=0; + while ((!done) && (c = *++argv[0])) /* allow multiletter options */ + switch (c) { + case 'c': + C = *++argv[0]; + if (C == '\0') { + argc--; C = *++argv[0]; + } + break; + case 'H': + if (*++argv[0] == '\0') { + argc--; argv++; + } + H = atoi(*argv); done = 1; + break; + case 'W': + if (*++argv[0] == '\0') { + argc--; argv++; + } + W = atoi(*argv); done = 1; + break; + default: + fatal("%s: %c illegal option\n", myname, c); + } + } + + if (argc == 0 || C == 0 || W*H == 0) + fatal("Usage: %s -c -W -H pkfile\n", myname); + + pkname = argv[0]; + pk_open(pkname); + + sprintf(comment, "Testfont %s designed at 10 points", pkname); + pk_preamble(comment, 10.0, 1473505522, 120, 120); + printf("character %c Width %d Height %d\n", C, W, H); + pk_char(C, 640796, 25, W, H, -2, 28, next_pixel); + pk_postamble(); + pk_close(); +} + +/* This function delivers the pixels from the character's bounding box + * from left to right and from top to bottom. + */ +int next_pixel() +{ int c; + do { c = getchar(); + if (c==EOF) fatal("reading past end of file!\n"); + if (c == '*' || c == 'X') return BLACK; + if (c == '.') return WHITE; + } while (1); +} + +/* The character example from GFtoPK: + ******************** + ******************** + ******************** + ******************** + **................** + **................** + **................** + .................... + .................... + ..**............**.. + ..**............**.. + ..**............**.. + ..****************.. + ..****************.. + ..****************.. + ..****************.. + ..**............**.. + ..**............**.. + ..**............**.. + .................... + .................... + .................... + **................** + **................** + **................** + ******************** + ******************** + ******************** + ******************** +*/ -- cgit v1.2.3