Xinqi Bao's Git
2 * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
12 textwidth_l(BlitzFont
*font
, char *text
, unsigned int len
)
16 XmbTextExtents(font
->set
, text
, len
, nil
, &r
);
19 return XTextWidth(font
->xfont
, text
, len
);
23 textwidth(BlitzFont
*font
, char *text
)
25 return blitz_textwidth_l(font
, text
, strlen(text
));
29 loadfont(Blitz
*blitz
, BlitzFont
*font
)
31 char *fontname
= font
->fontstr
;
32 char **missing
= nil
, *def
= "?";
35 setlocale(LC_ALL
, "");
37 XFreeFontSet(blitz
->dpy
, font
->set
);
38 font
->set
= XCreateFontSet(blitz
->dpy
, fontname
, &missing
, &n
, &def
);
41 fprintf(stderr
, "liblitz: missing fontset: %s\n", missing
[n
]);
42 XFreeStringList(missing
);
44 XFreeFontSet(blitz
->dpy
, font
->set
);
49 XFontSetExtents
*font_extents
;
54 font
->ascent
= font
->descent
= 0;
55 font_extents
= XExtentsOfFontSet(font
->set
);
56 n
= XFontsOfFontSet(font
->set
, &xfonts
, &font_names
);
57 for(i
= 0, font
->ascent
= 0, font
->descent
= 0; i
< n
; i
++) {
58 if(font
->ascent
< (*xfonts
)->ascent
)
59 font
->ascent
= (*xfonts
)->ascent
;
60 if(font
->descent
< (*xfonts
)->descent
)
61 font
->descent
= (*xfonts
)->descent
;
67 XFreeFont(blitz
->dpy
, font
->xfont
);
69 font
->xfont
= XLoadQueryFont(blitz
->dpy
, fontname
);
72 font
->xfont
= XLoadQueryFont(blitz
->dpy
, fontname
);
75 fprintf(stderr
, "%s", "liblitz: error, cannot load 'fixed' font\n");
78 font
->ascent
= font
->xfont
->ascent
;
79 font
->descent
= font
->xfont
->descent
;