8 static int o_f
, o_s
, o_m
; /* font and size */
9 static int o_h
, o_v
; /* current user position */
10 static int p_f
, p_s
, p_m
; /* output postscript font */
11 static int o_qtype
; /* queued character type */
12 static int o_qv
, o_qh
, o_qend
; /* queued character position */
13 char o_fonts
[FNLEN
* NFONTS
] = " ";
15 static void outvf(char *s
, va_list ap
)
17 vfprintf(stdout
, s
, ap
);
20 void outf(char *s
, ...)
28 static void o_flush(void)
31 outf(") %d %d w\n", o_qh
, o_qv
);
33 outf("] %d %d g\n", o_qh
, o_qv
);
47 static void o_queue(struct glyph
*g
)
49 int type
= 1 + !isdigit((g
)->id
[0]);
50 int num
= atoi(g
->id
);
51 if (o_qtype
!= type
|| o_qend
!= o_h
|| o_qv
!= o_v
) {
56 outf(type
== 1 ? "(" : "[");
59 if (num
>= ' ' && num
<= '~')
60 outf("%s%c", strchr("()\\", num
) ? "\\" : "", num
);
62 outf("\\%d%d%d", (num
>> 6) & 7, (num
>> 3) & 7, num
& 7);
66 o_qend
= o_h
+ charwid(g
->wid
, o_s
);
69 /* calls o_flush() if necessary */
70 void out(char *s
, ...)
79 /* glyph placement adjustments */
80 static struct fixlist
{
98 static void fixpos(struct glyph
*g
, int *dh
, int *dv
)
100 struct font
*fn
= g
->font
;
104 if (!strcmp("S", fn
->name
) && !strcmp("Symbol", fn
->fontname
)) {
105 for (i
= 0; i
< LEN(fixlist
); i
++) {
106 if (!strcmp(fixlist
[i
].name
, g
->name
)) {
107 *dh
= charwid(fixlist
[i
].dh
, o_s
);
108 *dv
= charwid(fixlist
[i
].dv
, o_s
);
115 static void out_fontup(int fid
)
120 out("%d %d %d rgb\n", CLR_R(o_m
), CLR_G(o_m
), CLR_B(o_m
));
123 if (fid
!= p_f
|| o_s
!= p_s
) {
125 out("%d /%s f\n", o_s
, fn
->fontname
);
128 sprintf(fnname
, " %s ", fn
->fontname
);
129 if (!strstr(o_fonts
, fnname
))
130 sprintf(strchr(o_fonts
, '\0'), "%s ", fn
->fontname
);
139 g
= dev_glyph(c
, o_f
);
140 fn
= g
? g
->font
: dev_font(o_f
);
142 outrel(*c
== ' ' && fn
? charwid(fn
->spacewid
, o_s
) : 1, 0);
145 out_fontup(dev_fontid(fn
));
164 void outrel(int h
, int v
)
175 /* a font was mounted at pos f */
192 static int draw_path
; /* number of path segments */
193 static int draw_point
; /* point was set for postscript newpath */
195 static void drawmv(void)
198 outf("%d %d m ", o_h
, o_v
);
202 /* start a multi-segment path */
203 void drawmbeg(char *s
)
208 outf("gsave newpath %s\n", s
);
211 /* end a multi-segment path */
212 void drawmend(char *s
)
216 outf("%s grestore\n", s
);
228 void drawend(int close
, int fill
)
241 void drawl(int h
, int v
)
245 outf("%d %d drawl ", o_h
, o_v
);
252 outf("%d %d drawe ", c
, c
);
255 void drawe(int h
, int v
)
259 outf("%d %d drawe ", h
, v
);
262 void drawa(int h1
, int v1
, int h2
, int v2
)
265 outf("%d %d %d %d drawa ", h1
, v1
, h2
, v2
);
266 outrel(h1
+ h2
, v1
+ v2
);
269 void draws(int h1
, int v1
, int h2
, int v2
)
272 outf("%d %d %d %d %d %d draws ", o_h
, o_v
, o_h
+ h1
, o_v
+ v1
,
273 o_h
+ h1
+ h2
, o_v
+ v1
+ v2
);