From 1f05aa7f2147253cbb6113fee155bdb613f6a2e5 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 14 Jun 2012 01:04:47 +0100 Subject: [PATCH] Minor improvement to text wrapping When text flows onto a new line, don't put the space between words at the start of the new line. --- src/graphics.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/graphics.c b/src/graphics.c index c82a20a95..9b19872d1 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1082,6 +1082,8 @@ int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, i rw = 0; y+=FONT_H+2; rh+=FONT_H+2; + if (*s==' ') + continue; } x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); } @@ -1194,6 +1196,8 @@ void textnpos(char *s, int n, int w, int *cx, int *cy) { x = 0; y += FONT_H+2; + if (*s==' ') + continue; } n--; } @@ -1236,6 +1240,8 @@ int textposxy(char *s, int width, int w, int h) if (x>=width) { x = 0; y += FONT_H+2; + if (*s==' ') + continue; } n++; } @@ -1274,6 +1280,8 @@ int textwrapheight(char *s, int width) { x = 0; height += FONT_H+2; + if (*s==' ') + continue; } x += cw; }