diff --git a/src/common/fonts/v_text.cpp b/src/common/fonts/v_text.cpp index 59d8434964..bfd6eac92e 100644 --- a/src/common/fonts/v_text.cpp +++ b/src/common/fonts/v_text.cpp @@ -88,7 +88,7 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { if (*string == '[') { - const uint8_t *start = string; + const uint8_t* start = string; while (*string != ']' && *string != '\0') { string++; @@ -97,11 +97,6 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { string++; } - lastcolor = FString((const char *)start, string - start); - } - else - { - lastcolor = *string++; } } continue; @@ -130,6 +125,33 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str } auto index = Lines.Reserve(1); + for (const uint8_t* pos = start; pos < space; pos++) + { + if (*pos == TEXTCOLOR_ESCAPE) + { + pos++; + if (*pos) + { + if (*pos == '[') + { + const uint8_t* cstart = pos; + while (*pos != ']' && *pos != '\0') + { + pos++; + } + if (*pos != '\0') + { + pos++; + } + lastcolor = FString((const char*)cstart, pos - start); + } + else + { + lastcolor = *pos++; + } + } + } + } breakit (&Lines[index], font, start, space, linecolor); if (c == '\n' && !preservecolor) {