8 static int o_f
, o_s
; /* font and size */
9 static int o_h
, o_v
; /* current user position */
10 static int p_f
, p_s
; /* 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
);
46 static void o_queue(struct glyph
*g
)
48 int type
= 1 + !isdigit((g
)->id
[0]);
49 int num
= atoi(g
->id
);
50 if (o_qtype
!= type
|| o_qend
!= o_h
|| o_qv
!= o_v
) {
55 outf(type
== 1 ? "(" : "[");
58 if (num
>= ' ' && num
<= '~')
59 outf("%s%c", strchr("()\\", num
) ? "\\" : "", num
);
61 outf("\\%d%d%d", (num
>> 6) & 7, (num
>> 3) & 7, num
& 7);
65 o_qend
= o_h
+ charwid(g
->wid
, o_s
);
68 /* calls o_flush() if necessary */
69 void out(char *s
, ...)
78 /* glyph placement adjustments */
79 static struct fixlist
{
91 static void fixpos(struct glyph
*g
, int *dh
, int *dv
)
93 struct font
*fn
= g
->font
;
97 if (!strcmp("S", fn
->name
)) {
98 for (i
= 0; i
< LEN(fixlist
); i
++) {
99 if (!strcmp(fixlist
[i
].name
, g
->name
)) {
100 *dh
= charwid(fixlist
[i
].dh
, o_s
);
101 *dv
= charwid(fixlist
[i
].dv
, o_s
);
108 static void out_fontup(int fid
)
112 if (fid
!= p_f
|| o_s
!= p_s
) {
114 out("%d /%s f\n", o_s
, fn
->psname
);
117 sprintf(fnname
, " %s ", fn
->psname
);
118 if (!strstr(o_fonts
, fnname
))
119 sprintf(strchr(o_fonts
, '\0'), "%s ", fn
->psname
);
128 g
= dev_glyph(c
, o_f
);
129 fn
= g
? g
->font
: dev_font(o_f
);
131 outrel(*c
== ' ' && fn
? charwid(fn
->spacewid
, o_s
) : 1, 0);
134 out_fontup(dev_fontid(fn
));
153 void outrel(int h
, int v
)
169 static int draw_path
; /* number of path segments */
170 static int draw_point
; /* point was set for postscript newpath */
172 static void drawmv(void)
175 outf("%d %d m ", o_h
, o_v
);
179 /* if s is not NULL, start a multi-segment path */
180 void drawbeg(char *s
)
186 draw_path
= s
!= NULL
;
188 outf("gsave newpath %s\n", s
);
193 void drawend(char *s
)
200 outf("%s grestore\n", s
);
205 void drawl(int h
, int v
)
209 outf("%d %d drawl ", o_h
, o_v
);
216 outf("%d %d drawe ", c
, c
);
219 void drawe(int h
, int v
)
223 outf("%d %d drawe ", h
, v
);
226 void drawa(int h1
, int v1
, int h2
, int v2
)
229 outf("%d %d %d %d drawa ", h1
, v1
, h2
, v2
);
230 outrel(h1
+ h2
, v1
+ v2
);
233 void draws(int h1
, int v1
, int h2
, int v2
)
236 outf("%d %d %d %d %d %d draws ", o_h
, o_v
, o_h
+ h1
, o_v
+ v1
,
237 o_h
+ h1
+ h2
, o_v
+ v1
+ v2
);