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
|
/* kyodev.c The kyocera output driver for dvi2kyo program.
* Copyright 1987 State University Groningen, Netherlands
* Author: kees@guvaxin.uucp
*/
#include <stdio.h>
#include "dev.h"
#include "kyo.h"
#define DEV_DPI 300 /* Device dots per inch */
#define DEV_XOFFSET 200
#define DEV_YOFFSET 300
FILE *dev_out;
long dev_h,dev_v;
unsigned long dev_options;
/* Map the ASCII codes 0-060 to 0240-0320
* because the Kyocera can not print symbols with
* codes 0-040 in each emulation mode, and the ASCII
* sequence !R! brings it into PRESCRIBE command mode
*/
unsigned char visual(ch)
unsigned long ch;
{
if (ch < 060) ch += 0240;
return((unsigned char)ch);
}
/* Print symbol "ch" from current font
* and update the horizontal cursor position
*/
dev_setc(ch,xsize)
unsigned long ch;
int xsize;
{
putc(visual(ch), dev_out);
dev_h += xsize;
}
/* Print symbol "c" by sending the pixel raster
* The raster info is converted to a vectorlike image
* and the symbol is printed by drawing lines
*/
dev_raster(c)
struct kyochar *c;
{
int i,w,row,l,s,bw;
unsigned short *bp, x;
debug("Output raster info\n");
bp = c->kc_glyph.p;
bw = (c->kc_width + 15) / 16;
fprintf(dev_out, "!R! SCP;MRP %1d,%1d;", -(c->kc_xoffset), -(c->kc_yoffset));
for (row=0; row<c->kc_height; row++) {
l = 0; s = 0;
fprintf(dev_out, "SCP;MRP 0,%1d;", row);
debug("row: %d\n", row);
for (w=0; w<bw; w++) {
x = *bp++;
if ((w % 8) == 0) debug("\n");
debug("%o ", x);
for (i=15; i>=0; i--)
if (x & (1 << i)) {
if (s) {
fprintf(dev_out, "MRP %1d,0;", s);
s = 0;
}
l++;
} else {
if (l) {
fprintf(dev_out, "DRP %1d,0;", l);
l = 0;
}
s++;
}
}
if (l) fprintf(dev_out, "DRP %1d,0;", l);
fprintf(dev_out, "RPP;");
}
fprintf(dev_out, "EXIT;");
}
/* Put the cursor on position "(x,y)" */
dev_position(x,y)
long x,y;
{
if ((dev_h != x) || (dev_v != y))
fprintf(dev_out, "!R! MAP %1d,%1d;EXIT;", x, y);
dev_h = x; dev_v = y;
}
/* Draw a filled rectangele */
dev_draw_box(h,w)
long h,w;
{
fprintf(dev_out, "!R! BLK %1d,%1d;EXIT;", w, -h);
}
/* End of page */
dev_eop()
{
fprintf(dev_out,"!R! PAGE;EXIT;");
fflush(dev_out);
dev_h = dev_v = 0;
}
/* Initialize Kyocera */
hard_init()
{
fprintf(dev_out, "!R! RES;UNIT D;SLM %1d;STM %1d;SPD 1;EXIT;"
, DEV_XOFFSET, DEV_YOFFSET);
page_init();
}
/* Initialization at each page begin */
page_init()
{
dev_h = dev_v = 0;
}
/* Initialization routine called by device independent part */
dev_init(f,options,dpi)
FILE *f;
unsigned long options;
long *dpi;
{
dev_out = f;
*dpi = DEV_DPI;
dev_options = options;
hard_init();
}
/* Terminate use of device */
dev_term()
{
fprintf(dev_out, "!R! PAGE;RES; EXIT;!R! RES; EXIT;");
fflush(dev_out);
}
/* Print error log */
dev_print_log(f)
FILE *f;
{
register int ch;
if (dev_h || dev_v) putc('\f',dev_out);
fprintf(dev_out, "!R! FONT 1;EXIT;");
while (!ferror(f) && (ch = getc(f)) != EOF) {
if (ch == '\n') putc('\r',dev_out);
putc(ch,dev_out);
}
putc('\f',dev_out);
fflush(dev_out);
}
/* Handle special DVI commands
* "nchars" are copied from file "f"
* directly to the Kyocera
*/
dev_special(nchars,f)
int nchars;
FILE *f;
{
while (nchars-- > 0) putc(getc(f),dev_out);
page_init();
}
|