From 4cfc650f5bca893b357dc0c20fe7186d354da745 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Jul 2019 21:40:17 +0200 Subject: [PATCH] - fixed line breaking on non-spaces for multi-byte UTF-8 characters. This needs to backtrack the entire code point, not just one byte. --- src/gamedata/fonts/v_text.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gamedata/fonts/v_text.cpp b/src/gamedata/fonts/v_text.cpp index ac176e12a..fbbbde9e1 100644 --- a/src/gamedata/fonts/v_text.cpp +++ b/src/gamedata/fonts/v_text.cpp @@ -125,7 +125,9 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str if ((w > 0 && w + nw > maxwidth) || c == '\n') { // Time to break the line if (!space) - space = string - 1; + { + for (space = string - 1; (*space & 0xc0) == 0x80 && space > start; space--); + } auto index = Lines.Reserve(1); breakit (&Lines[index], font, start, space, linecolor);