summaryrefslogtreecommitdiff
path: root/pxl/pxbfont.ps
blob: c2f0ee0754f0e72e8e6451ab65d8d69181bbc626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
%!
%    Copyright (C) 1996 Aladdin Enterprises.  All rights reserved.
%    Unauthorized use, copying, and/or distribution prohibited.

% Construct the bitmap font used for printing the error page.

% /usr/bin/gs -I/usr/lib/ghostscript -q -dNODISPLAY pxbfont.ps >pxbfont.c


% Put space last so we can fake the width.

/Chars
  ("\(\)-/0123456789:;?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz )
def
/Res 150 def
/Face /Courier def
/Points 24 def

% Write the copyright notice.
(/* Copyright (C) 1996 Aladdin Enterprises.  All rights reserved.
   Unauthorized use, copying, and/or distribution prohibited.
 */

#include "stdpre.h"
#include "pxbfont.h"
) print

% Create the character bitmaps.
(
const byte px_bitmap_font_char_data[] = {
) print
/Asc 0 def
/Desc 0 def
/Base Res 1 add 2 idiv def
/Sc Res 72 div def
% Round up the device width so there won't be trailing garbage bits
% when we read out the character bitmaps.
/ID [Sc 0 0 Sc neg 0 Res]
  Res dup neg 7 and add Res <ff 00> makeimagedevice def
nulldevice ID setdevice
/Row Res 7 add 8 idiv string def
/ZRow Row length string def
Face Points selectfont
/print16
 { dup 8 bitshift 255 and =only (, ) print 255 and =only
 } def
Chars
 { 1 string dup 0 4 -1 roll put /Ch exch def
   erasepage 0 36 moveto Ch show
   0 Res
	% Remove blank lines at bottom.
    { 2 copy eq { exit } if
      dup 1 sub ID exch Row copyscanlines ZRow ne { exit } if
      1 sub
    }
   loop
	% Remove blank lines at top.
    { 2 copy eq { exit } if
      1 index ID exch Row copyscanlines ZRow ne { exit } if
      exch 1 add exch
    }
   loop
	% Determine the character width.
   /B 0 def
   /W 0 def
   2 copy 1 sub 1 exch
    { ID exch Row copyscanlines pop
      Row length 1 sub -1 W
       { Row 1 index get dup 0 ne
	  { 1 index W eq { B or } if /B exch def /W exch def exit
	  }
	 if pop pop
       }
      for
    }
   for
   /WB W 8 mul 8 add B 16#100 or	% might be an empty character
    { dup 1 and 0 ne { pop exit } if
      exch 1 sub exch -1 bitshift
    }
   loop
   dup 0 eq { pop Asc 2 idiv } if def	% fake width of empty characters
   2 copy eq { pop pop Base dup } if	% empty character
   /Asc Asc Base 4 index sub max def
   /Desc Desc 2 index Base sub max def
	% Write the character code.
   (\t) print Ch 0 get =only ( /* ) print Ch =only ( */, ) print
	% Write the character header.
	% We use the PCL5 format, rather than the PCL XL format,
	% so that we can represent the inter-character spacing.
   (4, 0, 14, 1, 0, 0, 0, 0, ) =only
   Base 2 index sub print16 (, ) print
   WB print16 (, ) print
   2 copy exch sub print16 (, ) print
   WB 4 mul print16 (,) =
	% Write the bits.
   1 sub 1 exch
    { ID exch Row copyscanlines 0 W 1 add getinterval
       { =only (,) print
       } forall () =
    }
   for
 }
forall
(\t0
};
) print

% Create the font header.
(
const int px_bitmap_font_point_size = ) print Points =only (;
const int px_bitmap_font_resolution = ) print Res =only (;
) print
(const byte px_bitmap_font_header[] = {
  0, 0, 0, 14, 254, 0, 0, ) print Chars length =only (,
  'B', 'R', 0, 0, 0, 4,
	0, ) print Res =only (, 0, ) print Res =only (,
  0xff, 0xff, 0, 0, 0, 0
};
const uint px_bitmap_font_header_size = sizeof(px_bitmap_font_header);
) print

% All done.
flush quit