aboutsummaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/draw.c b/draw.c
index f952b53..2028fd9 100644
--- a/draw.c
+++ b/draw.c
@@ -120,24 +120,23 @@ initfont(DC *dc, const char *fontstr) {
120 120
121Bool 121Bool
122loadfont(DC *dc, const char *fontstr) { 122loadfont(DC *dc, const char *fontstr) {
123 char *def, **missing; 123 char *def, **missing, **names;
124 int i, n; 124 int i, n = 1;
125 XFontStruct **xfonts;
125 126
126 if(!*fontstr) 127 if(!*fontstr)
127 return False; 128 return False;
128 if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { 129 if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def)))
129 char **names;
130 XFontStruct **xfonts;
131
132 n = XFontsOfFontSet(dc->font.set, &xfonts, &names); 130 n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
133 for(i = dc->font.ascent = dc->font.descent = 0; i < n; i++) { 131 else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr)))
134 dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); 132 xfonts = &dc->font.xfont;
135 dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); 133 else
136 } 134 n = 0;
137 } 135
138 else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { 136 for(i = 0; i < n; i++) {
139 dc->font.ascent = dc->font.xfont->ascent; 137 dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent);
140 dc->font.descent = dc->font.xfont->descent; 138 dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
139 dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width);
141 } 140 }
142 if(missing) 141 if(missing)
143 XFreeStringList(missing); 142 XFreeStringList(missing);