all repos — openbox @ a4838c740cd52d4405fab019b73d118d02599c56

openbox fork - make it a bit more like ryudo

measure the font's height instead of listening to Xft
Dana Jansens danakj@orodu.net
commit

a4838c740cd52d4405fab019b73d118d02599c56

parent

5d62948cc5ace4dfa4c2543a53e9f7f7d9a86fff

2 files changed, 23 insertions(+), 2 deletions(-)

jump to
M render/font.crender/font.c

@@ -23,6 +23,22 @@ XFT_MAJOR, XFT_MINOR, XFT_REVISION);

#endif } +static void measure_height(ObFont *f) +{ + XGlyphInfo info; + char *str; + + /* XXX add some extended UTF8 characters in here? */ + str = "12345678900-qwertyuiopasdfghjklzxcvbnm" + "!@#$%^&*()_+QWERTYUIOPASDFGHJKLZXCVBNM" + "`~[]\\;',./{}|:\"<>?"; + + XftTextExtentsUtf8(ob_display, f->xftfont, + (FcChar8*)str, strlen(str), &info); + g_message("measured: %d", info.height); + f->height = (signed) info.height; +} + ObFont *font_open(char *fontstring) { ObFont *out;

@@ -31,6 +47,7 @@

if ((xf = XftFontOpenName(ob_display, ob_screen, fontstring))) { out = malloc(sizeof(ObFont)); out->xftfont = xf; + measure_height(out); return out; } g_warning(_("Unable to load font: %s\n"), fontstring);

@@ -39,6 +56,7 @@

if ((xf = XftFontOpenName(ob_display, ob_screen, "fixed"))) { out = malloc(sizeof(ObFont)); out->xftfont = xf; + measure_height(out); return out; } g_warning(_("Unable to load font: %s\n"), "fixed");

@@ -64,7 +82,7 @@ }

int font_height(ObFont *f, int shadow, int offset) { - return (signed) f->xftfont->height + (shadow ? offset : 0); + return f->height + (shadow ? offset : 0); } int font_max_char_width(ObFont *f)

@@ -93,7 +111,9 @@ c.color.blue = t->color->b | t->color->b << 8;

c.pixel = t->color->pixel; c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet - XftDrawStringUtf8(d, &c, t->font->xftfont, x, t->font->xftfont->ascent + y, + XftDrawStringUtf8(d, &c, t->font->xftfont, x, + t->font->xftfont->ascent + y - + (t->font->xftfont->height - t->font->height) / 2, (FcChar8*)t->string, strlen(t->string)); return; }
M render/render.hrender/render.h

@@ -99,6 +99,7 @@ } Surface;

typedef struct { XftFont *xftfont; + int height; } ObFont; typedef enum {