diff options
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -120,24 +120,23 @@ initfont(DC *dc, const char *fontstr) { | |||
120 | 120 | ||
121 | Bool | 121 | Bool |
122 | loadfont(DC *dc, const char *fontstr) { | 122 | loadfont(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); |