diff options
Diffstat (limited to 'src/kernel/tqfontengine_x11.cpp')
-rw-r--r-- | src/kernel/tqfontengine_x11.cpp | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/src/kernel/tqfontengine_x11.cpp b/src/kernel/tqfontengine_x11.cpp index 47078dea9..aa116b93d 100644 --- a/src/kernel/tqfontengine_x11.cpp +++ b/src/kernel/tqfontengine_x11.cpp @@ -1531,12 +1531,11 @@ static glyph_t getAdobeCharIndex(XftFont *font, int cmap, uint ucs4) return g; } -static uint getUnicode(const TQChar *str, int &i, const int len) +static uint getCodepoint(const TQChar *str, int &i, const int len) { 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 + ++i; // This is required for correct advancement when handling surrogate pairs return TQChar::surrogateToUcs4(str[i - 1], str[i]); } return str[i].unicode(); @@ -1551,7 +1550,7 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g int glyph_pos = 0; for ( int i = 0; i < len; ++i ) { - uint uc = getUnicode(str, i, len); + uint uc = getCodepoint(str, i, len); if ( uc == 0xa0 ) uc = 0x20; if ( mirrored ) @@ -1575,32 +1574,17 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g ++glyph_pos; } - if ( advances ) { - for ( int i = 0; i < glyph_pos; i++ ) { - glyph_t glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftGlyphExtents( TQPaintDevice::x11AppDisplay(), _font, &glyph, 1, &gi ); - advances[i] = gi.xOff; - if ( glyph < widthCacheSize && gi.xOff > 0 && gi.xOff < 0x100 ) - ((TQFontEngineXft *)this)->widthCache[glyph] = gi.xOff; - } - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } + if ( advances ) + { + recalcAdvances(glyph_pos, glyphs, advances); } *nglyphs = glyph_pos; return NoError; } - -void TQFontEngineXft::recalcAdvances( int len, glyph_t *glyphs, advance_t *advances ) +void TQFontEngineXft::recalcAdvances( int len, glyph_t *glyphs, advance_t *advances ) const { - for ( int i = 0; i < len; i++ ) { FT_UInt glyph = *(glyphs + i); advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; @@ -1999,20 +1983,22 @@ bool TQFontEngineXft::canRender( const TQChar *string, int len ) bool allExist = TRUE; if (_cmap != -1) { - for ( int i = 0; i < len; i++ ) { - if (!XftCharExists(0, _font, string[i].unicode()) - && getAdobeCharIndex(_font, _cmap, string[i].unicode()) == 0) { - allExist = FALSE; - break; - } - } + for ( int i = 0; i < len; i++ ) { + uint uc = getCodepoint(string, i, len); + if (!XftCharExists(0, _font, uc) + && getAdobeCharIndex(_font, _cmap, uc) == 0) { + allExist = FALSE; + break; + } + } } else { - for ( int i = 0; i < len; i++ ) { - if (!XftCharExists(0, _font, string[i].unicode())) { - allExist = FALSE; - break; - } - } + for ( int i = 0; i < len; i++ ) { + uint uc = getCodepoint(string, i, len); + if (!XftCharExists(0, _font, uc)) { + allExist = FALSE; + break; + } + } } return allExist; |