From 8c984c2440d7b085fbe6302fb60f472b1f3c79a2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 27 May 2013 19:26:37 -0700 Subject: [PATCH] Use better replacements for missing space chars. --- Core/Util/PPGeDraw.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 6e64c427d7..33fd9283c6 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -266,10 +266,35 @@ 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('?'); + if (c == NULL) { + // Try to use a replacement character, these come from the below table. + // http://unicode.org/cldr/charts/supplemental/character_fallback_substitutions.html + switch (cval) { + case 0x00A0: // NO-BREAK SPACE + case 0x2000: // EN QUAD + case 0x2001: // EM QUAD + case 0x2002: // EN SPACE + case 0x2003: // EM SPACE + case 0x2004: // THREE-PER-EM SPACE + case 0x2005: // FOUR-PER-EM SPACE + case 0x2006: // SIX-PER-EM SPACE + case 0x2007: // FIGURE SPACE + case 0x2008: // PUNCTUATION SPACE + case 0x2009: // THIN SPACE + case 0x200A: // HAIR SPACE + case 0x202F: // NARROW NO-BREAK SPACE + case 0x205F: // MEDIUM MATHEMATICAL + case 0x3000: // IDEOGRAPHIC SPACE + c = atlasfont.getChar(0x0020); + break; + + default: + c = atlasfont.getChar(0xFFFD); + break; + } + if (c == NULL) + c = atlasfont.getChar('?'); + } return c; }