From a03f41a845668a7af9fad6100533f9b77b3d3c62 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 16 Aug 2016 02:06:40 -0300 Subject: [PATCH] eeshow/text.c (text_fig): correct vertical alignment of multi-line text We used the first line as alignment point, not the last line. --- eeshow/text.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eeshow/text.c b/eeshow/text.c index 68754c8..4c7d94d 100644 --- a/eeshow/text.c +++ b/eeshow/text.c @@ -99,9 +99,15 @@ void text_fig(const struct text *txt, int color, unsigned layer) const char *s; int x = txt->x; int y = txt->y; + unsigned multiline = 0; - x += rx(0, align(txt->size, txt->vert), txt->rot); - y += ry(0, align(txt->size, txt->vert), txt->rot); + for (s = txt->s; *s; s++) + if (*s == '\n') + multiline += NEWLINE_SKIP * txt->size; + x += rx(0, align(txt->size + multiline, txt->vert) - multiline, + txt->rot); + y += ry(0, align(txt->size + multiline, txt->vert) - multiline, + txt->rot); while (1) { s = strtok(tmp, "\n"); if (!s)