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 int dev_mnt(int pos
, char *id
, char *name
)
33 if (strchr(name
, '/'))
36 sprintf(path
, "%s/dev%s/%s", dev_dir
, dev_dev
, name
);
41 font_close(fn_font
[pos
]);
42 if (fn_name
[pos
] != name
) /* ignore if fn_name[pos] is passed */
43 snprintf(fn_name
[pos
], sizeof(fn_name
[pos
]), "%s", id
);
48 int dev_open(char *dir
, char *dev
)
56 sprintf(path
, "%s/dev%s/DESC", dir
, dev
);
57 desc
= fopen(path
, "r");
60 while (fscanf(desc
, "%s", tok
) == 1) {
65 if (!strcmp("fonts", tok
)) {
66 fscanf(desc
, "%d", &fn_n
);
67 for (i
= 0; i
< fn_n
; i
++)
68 fscanf(desc
, "%s", fn_name
[i
+ 1]);
72 if (!strcmp("sizes", tok
)) {
73 while (fscanf(desc
, "%s", tok
) == 1)
74 if (!strcmp("0", tok
))
78 if (!strcmp("res", tok
)) {
79 fscanf(desc
, "%d", &dev_res
);
82 if (!strcmp("unitwidth", tok
)) {
83 fscanf(desc
, "%d", &dev_uwid
);
86 if (!strcmp("hor", tok
)) {
87 fscanf(desc
, "%d", &dev_hor
);
90 if (!strcmp("ver", tok
)) {
91 fscanf(desc
, "%d", &dev_ver
);
94 if (!strcmp("charset", tok
))
105 for (i
= 0; i
< NFONTS
; i
++) {
107 font_close(fn_font
[i
]);
112 struct glyph
*dev_glyph(char *c
, int fn
)
114 if (!strncmp("GID=", c
, 4))
115 return font_glyph(fn_font
[fn
], c
+ 4);
116 return font_find(fn_font
[fn
], c
);
119 /* return the font struct at pos */
120 struct font
*dev_font(int pos
)
122 return pos
>= 0 && pos
< NFONTS
? fn_font
[pos
] : NULL
;
125 int dev_fontid(struct font
*fn
)
128 for (i
= 0; i
< NFONTS
; i
++)
129 if (fn_font
[i
] == fn
)