From f108df907e2e021453d795d80722e06dfff2549f Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Fri, 22 Mar 2013 21:12:31 +0000 Subject: [PATCH] [Fix] Finaly think I fixed gl_printText properly!! --- src/font.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/font.c b/src/font.c index a3ec735..ce137c3 100644 --- a/src/font.c +++ b/src/font.c @@ -211,7 +211,7 @@ int gl_printText(const glFont* ft_font, const int width, const int height, len = (int)strlen(txt); // Limit size per line. - lastspace = 0; // Last ' ' or \n int text. + lastspace = -1; // Last ' ' or \n int text. n = 0; // Current width. i = 0; // Current position. p = -1; // Where we last drew up to. @@ -222,11 +222,12 @@ int gl_printText(const glFont* ft_font, const int width, const int height, if((txt[i] == ' ') || (txt[i] == '\n') || (txt[i] == '\0')) lastspace = i; - if(((n > width) && ((p != lastspace) && (p != -1))) + if(((n > width) && ((p != lastspace))) || (txt[i] == '\n') || (txt[i] == '\0')) { // Time to draw the line. m = 0; + if(lastspace == -1) lastspace = 0; for(j = 0; j < (lastspace-p-1); j++) { m += ft_font->w[(int)txt[p+j+1]]; if(m > width) break;