diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index bc529efe3b..4ed8713b4f 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -954,10 +954,7 @@ static void PPGeDecimateTextImages(int age) { } } -void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) { - if (!text) { - return; - } +static std::string PPGeSanitizeText(const std::string &text) { // Seen in Ratchet & Clank - Secret Agent. To match the output of the real thing, we have to remove // both the overlong encoding and "ENTR", whatever that is. If we just let SanitizeUTF8 remove // the overlong null, the rest of the string is missing in the bottom left corner (save size, etc). @@ -966,7 +963,14 @@ void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) { // TODO: Potentially if the string is only ended by a C080, ReplaceAll might overshoot :( std::string str = ReplaceAll(text, "\xC0\x80""ENTR", ""); // Then SanitizeUTF8 is needed to get rid of various other overlong encodings. - str = SanitizeUTF8(str); + return SanitizeUTF8(str); +} + +void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) { + if (!text) { + return; + } + std::string str = PPGeSanitizeText(text); if (str.empty()) { return; } @@ -1013,7 +1017,7 @@ static std::string CropLinesToCount(const std::string &s, int numLines) { } void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style) { - std::string s = text; + std::string s = PPGeSanitizeText(text); if (wrapHeight != 0.0f) { s = StripTrailingWhite(s); }