From 269c1f27fd5c6a937a795e6159487583af29dc6b Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 25 Apr 2018 11:33:09 +0100 Subject: [PATCH] Win32: Fixed a bug where certain unicode characters (> 0x8000) would not be displayed correctly on Windows --- modules/juce_graphics/native/juce_win32_Fonts.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/juce_graphics/native/juce_win32_Fonts.cpp b/modules/juce_graphics/native/juce_win32_Fonts.cpp index 02d8499cfb..a62151c3d5 100644 --- a/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -364,15 +364,14 @@ public: { const CharPointer_UTF16 utf16 (text.toUTF16()); const size_t numChars = utf16.length(); - HeapBlock results (numChars + 1); - results[numChars] = -1; + HeapBlock results (numChars); float x = 0; if (GetGlyphIndices (dc, utf16, (int) numChars, reinterpret_cast (results.getData()), GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR) { for (size_t i = 0; i < numChars; ++i) - x += getKerning (dc, results[i], results[i + 1]); + x += getKerning (dc, results[i], (i + 1) < numChars ? results[i + 1] : -1); } return x; @@ -382,8 +381,7 @@ public: { const CharPointer_UTF16 utf16 (text.toUTF16()); const size_t numChars = utf16.length(); - HeapBlock results (numChars + 1); - results[numChars] = -1; + HeapBlock results (numChars); float x = 0; if (GetGlyphIndices (dc, utf16, (int) numChars, reinterpret_cast (results.getData()), @@ -396,7 +394,7 @@ public: { resultGlyphs.add (results[i]); xOffsets.add (x); - x += getKerning (dc, results[i], results[i + 1]); + x += getKerning (dc, results[i], (i + 1) < numChars ? results[i + 1] : -1); } }