fix font width calculations
authorMarkus Teich <markus.teich@stusta.mhn.de>
Sat, 31 Oct 2015 17:07:07 +0000 (18:07 +0100)
committerMarkus Teich <markus.teich@stusta.mhn.de>
Sat, 31 Oct 2015 17:07:07 +0000 (18:07 +0100)
drw.c
sent.c

diff --git a/drw.c b/drw.c
index 196f53b3678eddfb0999510c62b1979a4d8d26be..93359675d750fc0490758fa09844608fdc2a41fc 100644 (file)
--- a/drw.c
+++ b/drw.c
@@ -379,7 +379,7 @@ unsigned int
 drw_fontset_getwidth(Drw *drw, const char *text) {
        if (!drw || !drw->fonts || !text)
                return 0;
-       return drw_text(drw, 0, 0, 0, 0, text, 0) + drw->fonts->h;
+       return drw_text(drw, 0, 0, 0, 0, text, 0);
 }
 
 void
diff --git a/sent.c b/sent.c
index b27d944dbbe36d161f848cbf8b7ab7f78233473d..9bda1781ee8971e4b3652f8f1a3048a1061f3420 100644 (file)
--- a/sent.c
+++ b/sent.c
@@ -312,17 +312,18 @@ void pngdraw(Image *img)
 void getfontsize(char *str, unsigned int *width, unsigned int *height)
 {
        size_t i;
-       size_t len = strlen(str);
 
        for (i = 0; i < NUMFONTSCALES; i++) {
                drw_setfontset(d, fonts[i]);
-               drw_font_getexts(fonts[i], str, len, width, height);
+               *height = fonts[i]->h;
+               *width = drw_fontset_getwidth(d, str);
                if (*width  > xw.uw || *height > xw.uh)
                        break;
        }
        if (i > 0) {
                drw_setfontset(d, fonts[i-1]);
-               drw_font_getexts(fonts[i-1], str, len, width, height);
+               *height = fonts[i-1]->h;
+               *width = drw_fontset_getwidth(d, str);
        }
        *width += d->fonts->h;
 }