wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit da728553665279edc4691094a78a8ada250099d7
parent 4beb05d26209a0e4f8fef0bc601c3a7860d1788a
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Sun, 23 Apr 2006 23:32:36 +0200

kept the structural introduction of BlitzFont for future UTF8 support after wmii-3


Diffstat:
cmd/wm/bar.c | 4++--
cmd/wm/client.c | 4++--
cmd/wmiimenu.c | 10+++++-----
liblitz/blitz.h | 3+--
liblitz/draw.c | 8++++----
liblitz/font.c | 29++++++++++-------------------
6 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c @@ -64,7 +64,7 @@ unsigned int height_of_bar() { enum { BAR_PADDING = 4 }; - return blitzfont.font->ascent + blitzfont.font->descent + BAR_PADDING; + return blitzfont.xfont->ascent + blitzfont.xfont->descent + BAR_PADDING; } void @@ -127,7 +127,7 @@ draw_bar() l->rect.y = 0; l->rect.width = brect.height; if(strlen(l->data)) - l->rect.width += XTextWidth(blitzfont.font, l->data, strlen(l->data)); + l->rect.width += XTextWidth(blitzfont.xfont, l->data, strlen(l->data)); l->rect.height = brect.height; w += l->rect.width; } diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -251,7 +251,7 @@ draw_client(Client *c) idx_of_frame(c->frame.data[c->sel]) + 1, c->frame.data[c->sel]->area->frame.size); d.align = CENTER; - d.rect.width = d.rect.height + XTextWidth(blitzfont.font, buf, strlen(buf)); + d.rect.width = d.rect.height + XTextWidth(blitzfont.xfont, buf, strlen(buf)); d.data = buf; blitz_drawlabel(dpy, &d); blitz_drawborder(dpy, &d); @@ -261,7 +261,7 @@ draw_client(Client *c) } /* tag bar */ - d.rect.width = d.rect.height + XTextWidth(blitzfont.font, c->tags, strlen(c->tags)); + d.rect.width = d.rect.height + XTextWidth(blitzfont.xfont, c->tags, strlen(c->tags)); d.data = c->tags; blitz_drawlabel(dpy, &d); blitz_drawborder(dpy, &d); diff --git a/cmd/wmiimenu.c b/cmd/wmiimenu.c @@ -68,7 +68,7 @@ update_offsets() return; for(i = curroff; i < item.size; i++) { - w += XTextWidth(draw.font.font, item.data[i], strlen(item.data[i])) + mrect.height; + w += XTextWidth(draw.font.xfont, item.data[i], strlen(item.data[i])) + mrect.height; if(w > mrect.width) break; } @@ -76,7 +76,7 @@ update_offsets() w = cmdw + 2 * seek; for(i = curroff; i > 0; i--) { - w += XTextWidth(draw.font.font, item.data[i], strlen(item.data[i])) + mrect.height; + w += XTextWidth(draw.font.xfont, item.data[i], strlen(item.data[i])) + mrect.height; if(w > mrect.width) break; } @@ -143,7 +143,7 @@ draw_menu() for(i = curroff; i < nextoff; i++) { draw.data = item.data[i]; draw.rect.x = offx; - draw.rect.width = XTextWidth(draw.font.font, draw.data, + draw.rect.width = XTextWidth(draw.font.xfont, draw.data, strlen(draw.data)) + mrect.height; offx += draw.rect.width; if(sel == i) { @@ -308,7 +308,7 @@ read_allitems() } if(maxname) - cmdw = XTextWidth(draw.font.font, maxname, max) + mrect.height; + cmdw = XTextWidth(draw.font.xfont, maxname, max) + mrect.height; } int @@ -359,7 +359,7 @@ main(int argc, char *argv[]) | SubstructureRedirectMask | SubstructureNotifyMask; mrect.width = DisplayWidth(dpy, screen); - mrect.height = draw.font.font->ascent + draw.font.font->descent + 4; + mrect.height = draw.font.xfont->ascent + draw.font.xfont->descent + 4; mrect.y = DisplayHeight(dpy, screen) - mrect.height; mrect.x = 0; diff --git a/liblitz/blitz.h b/liblitz/blitz.h @@ -21,8 +21,7 @@ typedef struct { } BlitzColor; typedef struct { - XFontStruct *font; - XFontSet set; + XFontStruct *xfont; } BlitzFont; typedef struct { diff --git a/liblitz/draw.c b/liblitz/draw.c @@ -66,12 +66,12 @@ xdrawtext(Display *dpy, BlitzDraw *d) len = strlen(d->data); cext_strlcpy(text, d->data, sizeof(text)); - XSetFont(dpy, d->gc, d->font.font->fid); - h = d->font.font->ascent + d->font.font->descent; - y = d->rect.y + d->rect.height / 2 - h / 2 + d->font.font->ascent; + XSetFont(dpy, d->gc, d->font.xfont->fid); + h = d->font.xfont->ascent + d->font.xfont->descent; + y = d->rect.y + d->rect.height / 2 - h / 2 + d->font.xfont->ascent; /* shorten text if necessary */ - while (len && (w = XTextWidth(d->font.font, text, len)) > d->rect.width) { + while (len && (w = XTextWidth(d->font.xfont, text, len)) > d->rect.width) { text[len - 1] = 0; len--; shortened = 1; diff --git a/liblitz/font.c b/liblitz/font.c @@ -12,24 +12,15 @@ void blitz_loadfont(Display *dpy, BlitzFont *font, char *fontstr) { - char *fontname = fontstr; - char **missing = nil, *def = "?"; - int nmissing; - if(font->set) - XFreeFontSet(dpy, font->set); - if(font->font) - XFreeFont(dpy, font->font); - font->font = XLoadQueryFont(dpy, fontname); - if (!font->font) { - fontname = "fixed"; - font->font = XLoadQueryFont(dpy, fontname); - if (!font->font) { - fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n"); - exit(1); - } - } - font->set = XCreateFontSet(dpy, fontname, &missing, &nmissing, &def); + if(font->xfont) + XFreeFont(dpy, font->xfont); + + font->xfont = XLoadQueryFont(dpy, fontstr); + if (!font->xfont) + font->xfont = XLoadQueryFont(dpy, "fixed"); - if(missing) - XFreeStringList(missing); + if (!font->xfont) { + fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n"); + exit(1); + } }