diff options
author | Werner Almesberger <werner@almesberger.net> | 2016-09-24 01:54:53 -0300 |
---|---|---|
committer | Werner Almesberger <werner@almesberger.net> | 2016-09-24 01:54:53 -0300 |
commit | 18e6fee580526958cdc141884062e5502312da6a (patch) | |
tree | 033ca117be754e8ca9b0ba2a468ba6cfd06b5e74 /gfx | |
parent | 92662815ab7866d560436dcd98fd0236013a8d96 (diff) | |
download | eeshow-18e6fee580526958cdc141884062e5502312da6a.tar.gz eeshow-18e6fee580526958cdc141884062e5502312da6a.tar.bz2 eeshow-18e6fee580526958cdc141884062e5502312da6a.zip |
gfx/fig.c (fig_text_width): don't count ~ (overlining) and UTF-8 extra chars
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/fig.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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; + } |