fix loadfont c805dcbe
Connor Lane Smith · 2011-07-22 18:16 1 file(s) · +13 −12
draw.c +13 −12
121 121
Bool
122 122
loadfont(DC *dc, const char *fontstr) {
123 123
	char *def, **missing, **names;
124 -
	int i, n = 1;
124 +
	int i, n;
125 125
	XFontStruct **xfonts;
126 126
127 127
	if(!*fontstr)
128 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 130
		n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
131 -
	else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr)))
132 -
		xfonts = &dc->font.xfont;
133 -
	else
134 -
		n = 0;
135 -
136 -
	for(i = 0; i < n; i++) {
137 -
		dc->font.ascent  = MAX(dc->font.ascent,  xfonts[i]->ascent);
138 -
		dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
139 -
		dc->font.width   = MAX(dc->font.width,   xfonts[i]->max_bounds.width);
131 +
		for(i = 0; i < n; i++) {
132 +
			dc->font.ascent  = MAX(dc->font.ascent,  xfonts[i]->ascent);
133 +
			dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
134 +
			dc->font.width   = MAX(dc->font.width,   xfonts[i]->max_bounds.width);
135 +
		}
136 +
	}
137 +
	else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) {
138 +
		dc->font.ascent  = dc->font.xfont->ascent;
139 +
		dc->font.descent = dc->font.xfont->descent;
140 +
		dc->font.width   = dc->font.xfont->max_bounds.width;
140 141
	}
141 142
	if(missing)
142 143
		XFreeStringList(missing);
143 -
	return (dc->font.set || dc->font.xfont);
144 +
	return dc->font.set || dc->font.xfont;
144 145
}
145 146
146 147
void