7 static char dev_dir
[PATHLEN
]; /* device directory */
8 static 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 device fonts */
19 static void skipline(FILE* filp
)
24 } while (c
!= '\n' && c
!= EOF
);
27 struct font
*dev_fontopen(char *name
)
30 if (strchr(name
, '/'))
33 sprintf(path
, "%s/dev%s/%s", dev_dir
, dev_dev
, name
);
34 return font_open(path
);
37 int dev_mnt(int pos
, char *id
, char *name
)
42 fn
= dev_fontopen(name
);
46 font_close(fn_font
[pos
]);
47 if (fn_name
[pos
] != name
) /* ignore if fn_name[pos] is passed */
48 snprintf(fn_name
[pos
], sizeof(fn_name
[pos
]), "%s", id
);
53 int dev_open(char *dir
, char *dev
)
61 sprintf(path
, "%s/dev%s/DESC", dir
, dev
);
62 desc
= fopen(path
, "r");
65 while (fscanf(desc
, "%s", tok
) == 1) {
70 if (!strcmp("fonts", tok
)) {
71 fscanf(desc
, "%d", &fn_n
);
72 for (i
= 0; i
< fn_n
; i
++)
73 fscanf(desc
, "%s", fn_name
[i
+ 1]);
77 if (!strcmp("sizes", tok
)) {
78 while (fscanf(desc
, "%s", tok
) == 1)
79 if (!strcmp("0", tok
))
83 if (!strcmp("res", tok
)) {
84 fscanf(desc
, "%d", &dev_res
);
87 if (!strcmp("unitwidth", tok
)) {
88 fscanf(desc
, "%d", &dev_uwid
);
91 if (!strcmp("hor", tok
)) {
92 fscanf(desc
, "%d", &dev_hor
);
95 if (!strcmp("ver", tok
)) {
96 fscanf(desc
, "%d", &dev_ver
);
99 if (!strcmp("charset", tok
))
110 for (i
= 0; i
< NFONTS
; i
++) {
112 font_close(fn_font
[i
]);
117 struct glyph
*dev_glyph(char *c
, int fn
)
119 if (!strncmp("GID=", c
, 4))
120 return font_glyph(fn_font
[fn
], c
+ 4);
121 return font_find(fn_font
[fn
], c
);
124 /* return the font struct at pos */
125 struct font
*dev_font(int pos
)
127 return pos
>= 0 && pos
< NFONTS
? fn_font
[pos
] : NULL
;
130 int dev_fontid(struct font
*fn
)
133 for (i
= 0; i
< NFONTS
; i
++)
134 if (fn_font
[i
] == fn
)