From 4920cd3eea7d51938a12ecd6203b6fc89076c87c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 17 Apr 2013 23:25:40 -0700 Subject: [PATCH] Use replacement chars for unknown PPGe characters. --- Core/Util/PPGeDraw.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index d1cdd15a58..9522c9e330 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -263,6 +263,16 @@ void PPGeEnd() } } +static const AtlasChar *PPGeGetChar(const AtlasFont &atlasfont, unsigned int cval) +{ + const AtlasChar *c = atlasfont.getChar(cval); + if (c == NULL) + c = atlasfont.getChar(0xFFFD); + if (c == NULL) + c = atlasfont.getChar('?'); + return c; +} + static void PPGeMeasureText(const char *text, float scale, float *w, float *h) { const AtlasFont &atlasfont = *ppge_atlas.fonts[0]; unsigned int cval; @@ -279,7 +289,7 @@ static void PPGeMeasureText(const char *text, float scale, float *w, float *h) { wacc = 0; lines++; } - const AtlasChar *c = atlasfont.getChar(cval); + const AtlasChar *c = PPGeGetChar(atlasfont, cval); if (c) { wacc += c->wx * scale; } @@ -322,7 +332,7 @@ void PPGeDrawText(const char *text, float x, float y, int align, float scale, u3 x = sx; continue; } - const AtlasChar *ch = atlasfont.getChar(cval); + const AtlasChar *ch = PPGeGetChar(atlasfont, cval); if (ch) { const AtlasChar &c = *ch; float cx1 = x + c.ox * scale;