diff options
Diffstat (limited to 'src/kernel/tqfontengine_x11.cpp')
-rw-r--r-- | src/kernel/tqfontengine_x11.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/kernel/tqfontengine_x11.cpp b/src/kernel/tqfontengine_x11.cpp index b3461a6ff..47078dea9 100644 --- a/src/kernel/tqfontengine_x11.cpp +++ b/src/kernel/tqfontengine_x11.cpp @@ -1531,16 +1531,15 @@ static glyph_t getAdobeCharIndex(XftFont *font, int cmap, uint ucs4) return g; } -static uint getChar(const TQChar *str, int &i, const int len) +static uint getUnicode(const TQChar *str, int &i, const int len) { - uint uc = str[i].unicode(); - if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) { - uint low = str[++i].unicode(); - if (low >= 0xdc00 && low < 0xe000) { - uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; - } + if (str[i].isHighSurrogate() && i < (len - 1) && str[i + 1].isLowSurrogate()) + { + ++i; // Don't delete this: it is required for correct + // advancement when handling surrogate pairs + return TQChar::surrogateToUcs4(str[i - 1], str[i]); } - return uc; + return str[i].unicode(); } TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const @@ -1552,7 +1551,7 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g int glyph_pos = 0; for ( int i = 0; i < len; ++i ) { - uint uc = getChar(str, i, len); + uint uc = getUnicode(str, i, len); if ( uc == 0xa0 ) uc = 0x20; if ( mirrored ) |