7 char dev_dir
[PATHLEN
]; /* device directory */
8 char dev_dev
[PATHLEN
]; /* output device name */
9 int dev_res
; /* device resolution */
10 int dev_uwid
; /* device unitwidth */
11 int dev_hor
; /* minimum horizontal movement */
12 int dev_ver
; /* minimum vertical movement */
15 static char fn_name
[NFONTS
][FNLEN
]; /* font names */
16 static struct font
*fn_font
[NFONTS
]; /* font structs */
17 static int fn_n
; /* number of mounted fonts */
19 static void skipline(FILE* filp
)
24 } while (c
!= '\n' && c
!= EOF
);
27 static void dev_prologue(void)
29 out("x T %s\n", dev_dev
);
30 out("x res %d %d %d\n", dev_res
, dev_hor
, dev_ver
);
34 int dev_mnt(int pos
, char *id
, char *name
)
38 sprintf(path
, "%s/dev%s/%s", dev_dir
, dev_dev
, name
);
43 font_close(fn_font
[pos
]);
44 if (fn_name
[pos
] != name
) /* ignore if fn_name[pos] is passed */
45 strcpy(fn_name
[pos
], id
);
47 out("x font %d %s\n", pos
, name
);
51 int dev_open(char *dir
, char *dev
)
59 sprintf(path
, "%s/dev%s/DESC", dir
, dev
);
60 desc
= fopen(path
, "r");
63 while (fscanf(desc
, "%s", tok
) == 1) {
68 if (!strcmp("fonts", tok
)) {
69 fscanf(desc
, "%d", &fn_n
);
70 for (i
= 0; i
< fn_n
; i
++)
71 fscanf(desc
, "%s", fn_name
[i
+ 1]);
75 if (!strcmp("sizes", tok
)) {
76 while (fscanf(desc
, "%s", tok
) == 1)
77 if (!strcmp("0", tok
))
81 if (!strcmp("res", tok
)) {
82 fscanf(desc
, "%d", &dev_res
);
85 if (!strcmp("unitwidth", tok
)) {
86 fscanf(desc
, "%d", &dev_uwid
);
89 if (!strcmp("hor", tok
)) {
90 fscanf(desc
, "%d", &dev_hor
);
93 if (!strcmp("ver", tok
)) {
94 fscanf(desc
, "%d", &dev_ver
);
97 if (!strcmp("charset", tok
))
103 for (i
= 0; i
< fn_n
; i
++)
105 dev_mnt(i
, fn_name
[i
], fn_name
[i
]);
109 static void dev_epilogue(void)
119 for (i
= 0; i
< fn_n
; i
++) {
121 font_close(fn_font
[i
]);
126 /* glyph handling functions */
128 struct glyph
*dev_glyph(char *c
, int fn
)
132 if ((c
[0] == c_ec
|| c
[0] == c_ni
) && c
[1] == c_ec
)
134 if (c
[0] == c_ec
&& c
[1] == '(')
137 g
= font_find(fn_font
[fn
], c
);
140 for (i
= 0; i
< fn_n
; i
++)
141 if (fn_font
[i
] && fn_font
[i
]->special
)
142 if ((g
= font_find(fn_font
[i
], c
)))
147 struct glyph
*dev_glyph_byid(char *id
, int fn
)
149 return font_glyph(fn_font
[fn
], id
);
152 int dev_kernpair(char *c1
, char *c2
)
157 /* return the mounted position of font */
158 int dev_pos(char *id
)
161 if (isdigit(id
[0])) {
163 if (num
< 0 || num
>= fn_n
|| !fn_font
[num
]) {
164 errmsg("bad font position\n");
169 for (i
= 1; i
< fn_n
; i
++)
170 if (!strcmp(fn_name
[i
], id
))
172 if (!strcmp(fn_name
[0], id
))
174 return dev_mnt(0, id
, id
);
177 /* return the font struct at pos */
178 struct font
*dev_font(int pos
)
180 return pos
>= 0 && pos
< fn_n
? fn_font
[pos
] : NULL
;
183 int dev_getcs(int fn
)
185 return dev_font(fn
)->cs
;
188 void dev_setcs(int fn
, int cs
)
191 dev_font(fn
)->cs
= cs
;
194 int dev_getbd(int fn
)
196 return dev_font(fn
)->bd
;
199 void dev_setbd(int fn
, int bd
)
202 dev_font(fn
)->bd
= bd
;