aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-07-22 18:16:57 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-07-22 18:16:57 +0100
commitc805dcbeaff38dfcf78bdcc10c863eb7e1bbc32d (patch)
tree597bd02748b696684ac46b6af00121c45e2629c1
parenta6cbc6c9a7b8cfbf7382a6a81450bf4466980a21 (diff)
fix loadfont
-rw-r--r--draw.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/draw.c b/draw.c
index d0beee8..76f0c54 100644
--- a/draw.c
+++ b/draw.c
@@ -121,26 +121,27 @@ initfont(DC *dc, const char *fontstr) {
121Bool 121Bool
122loadfont(DC *dc, const char *fontstr) { 122loadfont(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
146void 147void