summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx/fig.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gfx/fig.c b/gfx/fig.c
index 021321e..daa015a 100644
--- a/gfx/fig.c
+++ b/gfx/fig.c
@@ -217,11 +217,19 @@ static void fig_text(void *ctx, int x, int y, const char *s, unsigned size,
static unsigned fig_text_width(void *ctx, const char *s, unsigned size,
enum text_style style)
{
+ unsigned n = 0;
+
/*
* Note that we stretch the text size, so the ratio is larger than
* expressed here.
*/
- return strlen(s) * size * 1.0;
+
+ while (*s) {
+ n += (*s & 0xc0) != 0xc0 && *s != '~';
+ s++;
+ }
+ return n * size * 1.0;
+
}