6 static void skipline(FILE* filp
)
11 } while (c
!= '\n' && c
!= EOF
);
14 struct glyph
*font_find(struct font
*fn
, char *name
)
17 for (i
= 0; i
< fn
->n
; i
++)
18 if (!strcmp(name
, fn
->c
[i
]))
23 struct glyph
*font_glyph(struct font
*fn
, char *id
)
26 for (i
= 0; i
< fn
->nglyphs
; i
++)
27 if (!strcmp(fn
->glyphs
[i
].id
, id
))
28 return &fn
->glyphs
[i
];
32 static void font_charset(struct font
*fn
, FILE *fin
)
37 struct glyph
*glyph
= NULL
;
38 struct glyph
*prev
= NULL
;
41 if (fscanf(fin
, "%s", name
) != 1)
43 fscanf(fin
, "%s", tok
);
45 if (strcmp("\"", tok
)) {
47 fscanf(fin
, "%d %s", &type
, id
);
49 glyph
= &fn
->glyphs
[fn
->nglyphs
++];
50 strcpy(glyph
->id
, id
);
51 strcpy(glyph
->name
, name
);
57 strcpy(fn
->c
[fn
->n
], name
);
63 struct font
*font_open(char *path
)
65 struct font
*fn
= malloc(sizeof(*fn
));
68 fin
= fopen(path
, "r");
69 memset(fn
, 0, sizeof(*fn
));
70 while (fscanf(fin
, "%s", tok
) == 1) {
75 if (!strcmp("spacewidth", tok
)) {
76 fscanf(fin
, "%d", &fn
->spacewid
);
79 if (!strcmp("special", tok
)) {
83 if (!strcmp("name", tok
)) {
84 fscanf(fin
, "%s", fn
->name
);
87 if (!strcmp("fontname", tok
)) {
91 if (!strcmp("named", tok
)) {
95 if (!strcmp("ligatures", tok
)) {
96 while (fscanf(fin
, "%s", tok
) == 1)
97 if (!strcmp("0", tok
))
102 if (!strcmp("charset", tok
)) {
103 font_charset(fn
, fin
);
111 void font_close(struct font
*fn
)