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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* $Log: downloadfont.c,v $
* Revision 0.8 92/11/23 19:46:43 19:46:43 bt (Bo Thide')
* Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
*
* Revision 0.7 92/11/13 02:41:27 02:41:27 bt (Bo Thide')
* More bug fixes and improvements. Support for PaintJet XL
*
* Revision 0.6 92/11/10 21:47:44 21:47:44 bt (Bo Thide')
* Bug fixes. Added -R option. Better font handling.
*
* Revision 0.5 92/11/09 16:25:31 16:25:31 bt (Bo Thide')
* Rewrite of dospecial.c. Extended \special support
*
* Revision 0.4 92/11/08 02:45:46 02:45:46 bt (Bo Thide')
* Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
*
* Revision 0.3 92/08/24 12:45:38 12:45:38 bt (Bo Thide')
* Fixed 8 bit (dc font) support.
*
* Revision 0.2 92/08/23 17:28:56 17:28:56 bt (Bo Thide')
* Source cleaned up. Changed certain function calls. Removed globals.
*
* Revision 0.1 92/08/22 23:58:47 23:58:47 bt (Bo Thide')
* First Release.
* */
#include <math.h>
#include <stdio.h>
#include "globals.h"
#include "macros.h"
#include "pcl.h"
static char rcsid[] = "$Header: downloadfont.c,v 0.8 92/11/23 19:46:43 bt Exp $";
/* Download a font to the printer */
long downloadfont(bitfile, permfontsdown, device)
FILE *bitfile;
int permfontsdown;
short device;
{
int i;
int depth;
int max_depth;
int max_width;
int max_offset;
long memreq;
double fh4;
max_depth = max_width = max_offset = 0;
memreq = 4;
/* Specify font ID = nextfontdown and download each character */
fprintf(bitfile, PCL4_FONT_ID, font->down=nextfontdown--, fd.size);
if(verbose)
fprintf(stderr,"Downloading %d...\n",font->down);
for(i = font->bc ; i <= font->ec ; i++)
if((cbase + i)->use_count) {
pkcharinfo(i);
if(c_voffset > max_offset) max_offset = c_voffset;
if((depth = c_height-c_voffset) > max_depth)
max_depth = depth;
if(c_width > max_width) max_width = c_width;
}
/* Determine the font descriptor values */
fd.size = 64;
fd.descriptor = 0;
if(device == DEV_LJPLUS)
fd.font_type = 1;
else
fd.font_type = 2;
fd.style_MSB = 0;
fd.reserved = 0;
fd.baseline = (ushort)max_offset;
fd.cell_width = (ushort)(max_width?max_width:1);
fd.cell_height = (ushort)(max_depth?max_offset+max_depth:max_offset+1);
fd.orientation = (ubyte)(landscape ? 1 : 0);
fd.spacing = 1;
fd.symbol_set = (ushort)(DYNAMICFONTBASE-nextfontdown-permfontsdown)<<5;
fd.pitch = fd.cell_width << 2;
fh4 = 4.0*font->height; /* Temp variable */
fd.height = (ushort)fh4;
pkcharinfo('x'); /* Get global values for 'x' */
fd.x_height = (ushort)c_height; /* c_height is for 'x' here! */
fd.width_type = 0;
fd.style_LSB = 0;
fd.stroke_weight = 0;
fd.typeface_LSB = 0;
fd.typeface_MSB = 0;
fd.serif_style = 128; /* Serif */
fd.quality = 0;
fd.placement = 0;
fd.underl_dist = (byte)-max_depth;
fd.underl_height = 0;
fd.text_height = fd.cell_height << 2;
fd.text_width = fd.cell_width << 2;
fd.first_code = 1;
fd.last_code = 255;
fd.pitch_ext = 0;
fd.height_ext = (ushort)(1024*(fh4 - fd.height));
fd.cap_height = 0;
fd.font_number = 0;
strcpy(fd.font_name,"-TeX dvi font-");
#ifdef DEBUG2
fprintf(stderr,"downloadfont: fd.size = %d\n", fd.size);
fprintf(stderr,"downloadfont: fd.descriptor = %d\n", fd.descriptor);
fprintf(stderr,"downloadfont: fd.font_type = %d\n", fd.font_type);
fprintf(stderr,"downloadfont: fd.style_MSB = %d\n", fd.style_MSB);
fprintf(stderr,"downloadfont: fd.reserved = %d\n", fd.reserved);
fprintf(stderr,"downloadfont: fd.baseline = %d\n", fd.baseline);
fprintf(stderr,"downloadfont: fd.cell_width = %d\n", fd.cell_width);
fprintf(stderr,"downloadfont: fd.cell_height = %d\n", fd.cell_height);
fprintf(stderr,"downloadfont: fd.orientation = %d\n", fd.orientation);
fprintf(stderr,"downloadfont: fd.spacing = %d\n", fd.spacing);
fprintf(stderr,"downloadfont: fd.symbol_set = %d\n", fd.symbol_set);
fprintf(stderr,"downloadfont: fd.pitch = %d\n", fd.pitch);
fprintf(stderr,"downloadfont: fd.height = %d\n", fd.height);
fprintf(stderr,"downloadfont: fd.x_height = %d\n", fd.x_height);
fprintf(stderr,"downloadfont: fd.width_type = %d\n", fd.width_type);
fprintf(stderr,"downloadfont: fd.style_LSB = %d\n", fd.style_LSB);
fprintf(stderr,"downloadfont: fd.stroke_weight = %d\n", fd.stroke_weight);
fprintf(stderr,"downloadfont: fd.typeface_LSB = %d\n", fd.typeface_LSB);
fprintf(stderr,"downloadfont: fd.typeface_MSB = %d\n", fd.typeface_MSB);
fprintf(stderr,"downloadfont: fd.serif_style = %d\n", fd.serif_style);
fprintf(stderr,"downloadfont: fd.quality = %d\n", fd.quality);
fprintf(stderr,"downloadfont: fd.placement = %d\n", fd.placement);
fprintf(stderr,"downloadfont: fd.underl_dist = %d\n", fd.underl_dist);
fprintf(stderr,"downloadfont: fd.underl_height = %d\n", fd.underl_height);
fprintf(stderr,"downloadfont: fd.text_height = %d\n", fd.text_height);
fprintf(stderr,"downloadfont: fd.text_width = %d\n", fd.text_width);
fprintf(stderr,"downloadfont: fd.first_code = %d\n", fd.first_code);
fprintf(stderr,"downloadfont: fd.last_code = %d\n", fd.last_code);
fprintf(stderr,"downloadfont: fd.pitch_ext = %d\n", fd.pitch_ext);
fprintf(stderr,"downloadfont: fd.height_ext = %d\n", fd.height_ext);
fprintf(stderr,"downloadfont: fd.cap_height = %d\n", fd.cap_height);
fprintf(stderr,"downloadfont: fd.font_number = %d\n", fd.font_number);
fprintf(stderr,"downloadfont: fd.font_name = %s\n", fd.font_name);
#endif /* DEBUG2 */
/* Send font descriptor escape sequence to printer */
fprintf(bitfile, PCL4_FONT_DESCR, fd.size);
/*
* Download each font descriptor value individually to avoid
* possible struct alignment problems.
*/
fwrite((void *)&fd.size, sizeof(fd.size), 1, bitfile);
fwrite((void *)&fd.descriptor, sizeof(fd.descriptor), 1, bitfile);
fwrite((void *)&fd.font_type, sizeof(fd.font_type), 1, bitfile);
fwrite((void *)&fd.style_MSB, sizeof(fd.style_MSB), 1, bitfile);
fwrite((void *)&fd.reserved, sizeof(fd.reserved), 1, bitfile);
fwrite((void *)&fd.baseline, sizeof(fd.baseline), 1, bitfile);
fwrite((void *)&fd.cell_width, sizeof(fd.cell_width), 1, bitfile);
fwrite((void *)&fd.cell_height, sizeof(fd.cell_height), 1, bitfile);
fwrite((void *)&fd.orientation, sizeof(fd.orientation), 1, bitfile);
fwrite((void *)&fd.spacing, sizeof(fd.spacing), 1, bitfile);
fwrite((void *)&fd.symbol_set, sizeof(fd.symbol_set), 1, bitfile);
fwrite((void *)&fd.pitch, sizeof(fd.pitch), 1, bitfile);
fwrite((void *)&fd.height, sizeof(fd.height), 1, bitfile);
fwrite((void *)&fd.x_height, sizeof(fd.x_height), 1, bitfile);
fwrite((void *)&fd.width_type, sizeof(fd.width_type), 1, bitfile);
fwrite((void *)&fd.style_LSB, sizeof(fd.style_LSB), 1, bitfile);
fwrite((void *)&fd.stroke_weight, sizeof(fd.stroke_weight), 1, bitfile);
fwrite((void *)&fd.typeface_LSB, sizeof(fd.typeface_LSB), 1, bitfile);
fwrite((void *)&fd.typeface_MSB, sizeof(fd.typeface_MSB), 1, bitfile);
fwrite((void *)&fd.serif_style, sizeof(fd.serif_style), 1, bitfile);
fwrite((void *)&fd.quality, sizeof(fd.quality), 1, bitfile);
fwrite((void *)&fd.placement, sizeof(fd.placement), 1, bitfile);
fwrite((void *)&fd.underl_dist, sizeof(fd.underl_dist), 1, bitfile);
fwrite((void *)&fd.underl_height, sizeof(fd.underl_height), 1, bitfile);
fwrite((void *)&fd.text_height, sizeof(fd.text_height), 1, bitfile);
fwrite((void *)&fd.text_width, sizeof(fd.text_width), 1, bitfile);
fwrite((void *)&fd.first_code, sizeof(fd.first_code), 1, bitfile);
fwrite((void *)&fd.last_code, sizeof(fd.last_code), 1, bitfile);
fwrite((void *)&fd.pitch_ext, sizeof(fd.pitch_ext), 1, bitfile);
fwrite((void *)&fd.height_ext, sizeof(fd.height_ext), 1, bitfile);
fwrite((void *)&fd.cap_height, sizeof(fd.cap_height), 1, bitfile);
fwrite((void *)&fd.font_number, sizeof(fd.font_number), 1, bitfile);
fwrite((void *)fd.font_name, sizeof(fd.font_name), 1, bitfile);
/* Download each character of curfont which occurs in the .dvi file */
for(i = font->bc ; i <= font->ec ; i++)
if((cbase + i)->use_count)
memreq += downloadchar(bitfile, i, device);
fprintf(bitfile, PCL4_MAKE_FONT_TEMP); /* Make the font temporary */
return(memreq);
}
|