aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-06-18 22:11:19 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-06-18 22:11:19 +0100
commitf7cbe710a266448122d89a02b8ba8c70423fc750 (patch)
tree63c7ad01d96e9d1f295910c99235ae18498270b3
parent723cbabc122292cc87474fd203e199e392206640 (diff)
update draw.c
-rw-r--r--draw.c27
-rw-r--r--draw.h1
2 files changed, 14 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);
diff --git a/draw.h b/draw.h
index 247c0b3..43a57bf 100644
--- a/draw.h
+++ b/draw.h
@@ -15,6 +15,7 @@ typedef struct {
15 int ascent; 15 int ascent;
16 int descent; 16 int descent;
17 int height; 17 int height;
18 int width;
18 XFontSet set; 19 XFontSet set;
19 XFontStruct *xfont; 20 XFontStruct *xfont;
20 } font; 21 } font;