diff options
-rw-r--r-- | draw.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -121,26 +121,27 @@ initfont(DC *dc, const char *fontstr) { | |||
121 | Bool | 121 | Bool |
122 | loadfont(DC *dc, const char *fontstr) { | 122 | loadfont(DC *dc, const char *fontstr) { |
123 | char *def, **missing, **names; | 123 | char *def, **missing, **names; |
124 | int i, n = 1; | 124 | int i, n; |
125 | XFontStruct **xfonts; | 125 | XFontStruct **xfonts; |
126 | 126 | ||
127 | if(!*fontstr) | 127 | if(!*fontstr) |
128 | return False; | 128 | return False; |
129 | if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) | 129 | if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { |
130 | n = XFontsOfFontSet(dc->font.set, &xfonts, &names); | 130 | n = XFontsOfFontSet(dc->font.set, &xfonts, &names); |
131 | else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) | 131 | for(i = 0; i < n; i++) { |
132 | xfonts = &dc->font.xfont; | 132 | dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); |
133 | else | 133 | dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); |
134 | n = 0; | 134 | dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width); |
135 | 135 | } | |
136 | for(i = 0; i < n; i++) { | 136 | } |
137 | dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); | 137 | else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { |
138 | dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); | 138 | dc->font.ascent = dc->font.xfont->ascent; |
139 | dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width); | 139 | dc->font.descent = dc->font.xfont->descent; |
140 | dc->font.width = dc->font.xfont->max_bounds.width; | ||
140 | } | 141 | } |
141 | if(missing) | 142 | if(missing) |
142 | XFreeStringList(missing); | 143 | XFreeStringList(missing); |
143 | return (dc->font.set || dc->font.xfont); | 144 | return dc->font.set || dc->font.xfont; |
144 | } | 145 | } |
145 | 146 | ||
146 | void | 147 | void |