~reviczky/luatex/texlive-bin-git

« back to all changes in this revision

Viewing changes to texk/ps2pkm/pktest.c

  • Committer: Adam Reviczky
  • Date: 2015-04-26 22:40:47 UTC
  • Revision ID: adam.reviczky@kclalumni.net-20150426224047-i2p26n3wqphupq6z
TeX Live 2015 import (rev. 37052)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * FILE:     pktest.c 
3
 
 *
4
 
 * PURPOSE:  This program demonstrates how a PK file can be created from
5
 
 *           a single character bitmap.
6
 
 *
7
 
 * USAGE:    pktest -c<char_code> -W<with> -H<Height> pkname < test.bm
8
 
 *           (test.bm contains the character from `The GFtoPK processor')
9
 
 *
10
 
 * VERSION:  Febr. 1992
11
 
 *
12
 
 * AUTHOR:   Piet Tutelaers (rcpt@urc.tue.nl)
13
 
 */
14
 
 
15
 
int testing = 1;
16
 
#include <stdio.h>
17
 
#include "basics.h"     /* fatal() */
18
 
#include "pkout.h"
19
 
 
20
 
main(int argc, char *argv[])
21
 
{
22
 
   int done, C = 0, W = 0, H = 0, c;
23
 
   char *myname, *pkname, comment[256];
24
 
   int next_pixel();
25
 
        
26
 
   myname = argv[0];
27
 
   while (--argc > 0 && (*++argv)[0] == '-') {
28
 
      done=0;
29
 
      while ((!done) && (c = *++argv[0])) /* allow multiletter options */
30
 
         switch (c) {
31
 
         case 'c':
32
 
            C = *++argv[0];
33
 
            if (C == '\0') {
34
 
               argc--;  C = *++argv[0];
35
 
            }
36
 
            break;
37
 
         case 'H':
38
 
            if (*++argv[0] == '\0') {
39
 
               argc--;  argv++;
40
 
            }
41
 
            H = atoi(*argv); done = 1;
42
 
            break;
43
 
         case 'W':
44
 
            if (*++argv[0] == '\0') {
45
 
               argc--;  argv++;
46
 
            }
47
 
            W = atoi(*argv); done = 1;
48
 
            break;
49
 
         default:
50
 
            fatal("%s: %c illegal option\n", myname, c);
51
 
         }
52
 
   }
53
 
 
54
 
   if (argc == 0 || C == 0 || W*H == 0)
55
 
      fatal("Usage: %s -c<char> -W<width> -H<height> pkfile\n", myname);
56
 
 
57
 
   pkname = argv[0];
58
 
   pk_open(pkname);
59
 
   
60
 
   sprintf(comment, "Testfont %s designed at 10 points", pkname);
61
 
   pk_preamble(comment, 10.0, 1473505522, 120, 120);
62
 
   printf("character %c Width %d Height %d\n", C, W, H);
63
 
   pk_char(C, 640796, 25, W, H, -2, 28, next_pixel);
64
 
   pk_postamble();
65
 
   pk_close();
66
 
}
67
 
 
68
 
/* This function delivers the pixels from the character's bounding box
69
 
 * from left to right and from top to bottom.
70
 
 */
71
 
int next_pixel()
72
 
{  int c;
73
 
   do { c = getchar();
74
 
      if (c==EOF) fatal("reading past end of file!\n");
75
 
      if (c == '*' || c == 'X') return BLACK;
76
 
      if (c == '.') return WHITE;
77
 
   } while (1);
78
 
}
79
 
 
80
 
/* The character example from GFtoPK:
81
 
  ********************
82
 
  ********************
83
 
  ********************
84
 
  ********************
85
 
  **................**
86
 
  **................**
87
 
  **................**
88
 
  ....................
89
 
  ....................
90
 
  ..**............**..
91
 
  ..**............**..
92
 
  ..**............**..
93
 
  ..****************..
94
 
  ..****************..
95
 
  ..****************..
96
 
  ..****************..
97
 
  ..**............**..
98
 
  ..**............**..
99
 
  ..**............**..
100
 
  ....................
101
 
  ....................
102
 
  ....................
103
 
  **................**
104
 
  **................**
105
 
  **................**
106
 
  ********************
107
 
  ********************
108
 
  ********************
109
 
  ********************
110
 
*/