mirror of
https://github.com/0intro/wmii
synced 2025-03-14 02:33:15 +03:00
kept the structural introduction of BlitzFont for future UTF8 support after wmii-3
This commit is contained in:
parent
4beb05d262
commit
da72855366
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -21,8 +21,7 @@ typedef struct {
|
||||
} BlitzColor;
|
||||
|
||||
typedef struct {
|
||||
XFontStruct *font;
|
||||
XFontSet set;
|
||||
XFontStruct *xfont;
|
||||
} BlitzFont;
|
||||
|
||||
typedef struct {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
if(missing)
|
||||
XFreeStringList(missing);
|
||||
font->xfont = XLoadQueryFont(dpy, fontstr);
|
||||
if (!font->xfont)
|
||||
font->xfont = XLoadQueryFont(dpy, "fixed");
|
||||
|
||||
if (!font->xfont) {
|
||||
fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user