summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-24 04:54:53 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-24 04:54:53 (GMT)
commit18e6fee580526958cdc141884062e5502312da6a (patch)
tree033ca117be754e8ca9b0ba2a468ba6cfd06b5e74 /gfx
parent92662815ab7866d560436dcd98fd0236013a8d96 (diff)
downloadeeshow-18e6fee580526958cdc141884062e5502312da6a.zip
eeshow-18e6fee580526958cdc141884062e5502312da6a.tar.gz
eeshow-18e6fee580526958cdc141884062e5502312da6a.tar.bz2
gfx/fig.c (fig_text_width): don't count ~ (overlining) and UTF-8 extra chars
Diffstat (limited to 'gfx')
-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;
+
}