diff options
Diffstat (limited to 'src/kernel/qfontengine_x11.cpp')
-rw-r--r-- | src/kernel/qfontengine_x11.cpp | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/src/kernel/qfontengine_x11.cpp b/src/kernel/qfontengine_x11.cpp index 46cdf4bf0..47ddb9367 100644 --- a/src/kernel/qfontengine_x11.cpp +++ b/src/kernel/qfontengine_x11.cpp @@ -1444,63 +1444,27 @@ public: }; -#ifdef QT_XFT2 static inline void getGlyphInfo( XGlyphInfo *xgi, XftFont *font, int glyph ) { FT_UInt x = glyph; XftGlyphExtents( TQPaintDevice::x11AppDisplay(), font, &x, 1, xgi ); } -#else -static inline XftFontStruct *getFontStruct( XftFont *font ) -{ - if (font->core) - return 0; - return font->u.ft.font; -} - -static inline void getGlyphInfo(XGlyphInfo *xgi, XftFont *font, int glyph) -{ - - XftTextExtents32(TQPaintDevice::x11AppDisplay(), font, (XftChar32 *) &glyph, 1, xgi); -} -#endif // QT_XFT2 static inline FT_Face lockFTFace( XftFont *font ) { -#ifdef QT_XFT2 return XftLockFace( font ); -#else - if (font->core) return 0; - return font->u.ft.font->face; -#endif // QT_XFT2 } static inline void unlockFTFace( XftFont *font ) { -#ifdef QT_XFT2 XftUnlockFace( font ); -#else - Q_UNUSED( font ); -#endif // QT_XFT2 } - - TQFontEngineXft::TQFontEngineXft( XftFont *font, XftPattern *pattern, int cmap ) : _font( font ), _pattern( pattern ), _openType( 0 ), _cmap( cmap ) { _face = lockFTFace( _font ); -#ifndef QT_XFT2 - XftFontStruct *xftfs = getFontStruct( _font ); - if ( xftfs ) { - // dirty hack: we set the charmap in the Xftfreetype to -1, so - // XftFreetype assumes no encoding and really draws glyph - // indices. The FT_Face still has the Unicode encoding to we - // can convert from Unicode to glyph index - xftfs->charmap = -1; - } -#else _cmap = -1; // Xft maps Unicode and adobe roman for us. for (int i = 0; i < _face->num_charmaps; ++i) { @@ -1513,8 +1477,6 @@ TQFontEngineXft::TQFontEngineXft( XftFont *font, XftPattern *pattern, int cmap ) break; } } -#endif // QT_XFT2 - cache_cost = _font->height * _font->max_advance_width * ( _face ? _face->num_glyphs : 1024 ); @@ -1552,7 +1514,6 @@ TQFontEngineXft::~TQFontEngineXft() } } -#ifdef QT_XFT2 static glyph_t getAdobeCharIndex(XftFont *font, int cmap, uint ucs4) { FT_Face _face = XftLockFace( font ); @@ -1561,7 +1522,6 @@ static glyph_t getAdobeCharIndex(XftFont *font, int cmap, uint ucs4) XftUnlockFace(font); return g; } -#endif TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const { @@ -1570,7 +1530,6 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g return OutOfMemory; } -#ifdef QT_XFT2 if (_cmap != -1) { for ( int i = 0; i < len; ++i ) { unsigned short uc = str[i].unicode(); @@ -1631,73 +1590,6 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g advances[i] = tqRound(advances[i]*_scale); } } -#else - if ( !_face ) { - if ( mirrored ) { - for ( int i = 0; i < len; i++ ) - glyphs[i] = ::mirroredChar(str[i]).unicode(); - } else { - for ( int i = 0; i < len; i++ ) - glyphs[i] = str[i].unicode(); - } - } else { - if ( _cmap == 1 ) { - // symbol font - for ( int i = 0; i < len; i++ ) { - unsigned short uc = str[i].unicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - if(!glyph && uc < 0x100) - glyph = FT_Get_Char_Index( _face, uc+0xf000 ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else if ( mirrored ) { - for ( int i = 0; i < len; i++ ) { - unsigned short uc = ::mirroredChar(str[i]).unicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else { - for ( int i = 0; i < len; i++ ) { - unsigned short uc = str[i].unicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } - } - - if ( advances ) { - for ( int i = 0; i < len; i++ ) { - XftChar16 glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftTextExtents16(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); - } - } -#endif // QT_XFT2 *nglyphs = len; return NoError; @@ -1707,7 +1599,6 @@ TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, g void TQFontEngineXft::recalcAdvances( int len, glyph_t *glyphs, advance_t *advances ) { -#ifdef QT_XFT2 for ( int i = 0; i < len; i++ ) { FT_UInt glyph = *(glyphs + i); advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; @@ -1723,23 +1614,6 @@ void TQFontEngineXft::recalcAdvances( int len, glyph_t *glyphs, advance_t *advan advances[i] = tqRound(advances[i]*_scale); } } -#else - for ( int i = 0; i < len; i++ ) { - XftChar16 glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftTextExtents16(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); - } -#endif // QT_XFT2 } //#define FONTENGINE_DEBUG @@ -1817,16 +1691,6 @@ void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engi XftPatternAddMatrix( pattern, XFT_MATRIX, &m2 ); fnt = XftFontOpenPattern( dpy, pattern ); -#ifndef QT_XFT2 - XftFontStruct *xftfs = getFontStruct( fnt ); - if ( xftfs ) { - // dirty hack: we set the charmap in the Xftfreetype to -1, so - // XftFreetype assumes no encoding and really draws glyph - // indices. The FT_Face still has the Unicode encoding to we - // can convert from Unicode to glyph index - xftfs->charmap = -1; - } -#endif // QT_XFT2 TransformedFont *trf = new TransformedFont; trf->xx = (float)m2.xx; trf->xy = (float)m2.xy; @@ -1882,14 +1746,9 @@ void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engi int yp = y + offsets[i].y; if ( transform ) p->map( xp, yp, &xp, &yp ); -#ifdef QT_XFT2 FT_UInt glyph = *(glyphs + i); if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) XftDrawGlyphs( draw, &col, fnt, xp, yp, &glyph, 1 ); -#else - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawString16( draw, &col, fnt, xp, yp, (XftChar16 *) (glyphs+i), 1); -#endif // QT_XFT2 #ifdef FONTENGINE_DEBUG glyph_metrics_t gi = boundingBox( glyphs[i] ); p->drawRect( x+offsets[i].x+gi.x, y+offsets[i].y+100+gi.y, gi.width, gi.height ); @@ -1907,14 +1766,9 @@ void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engi int yp = y + offsets[i].y; if ( transform ) p->map( xp, yp, &xp, &yp ); -#ifdef QT_XFT2 FT_UInt glyph = *(glyphs + i); if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) XftDrawGlyphs( draw, &col, fnt, xp, yp, &glyph, 1 ); -#else - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawString16( draw, &col, fnt, xp, yp, (XftChar16 *) (glyphs+i), 1 ); -#endif // QT_XFT2 // tqDebug("advance = %d/%d", adv.x, adv.y ); x += advances[i]; i++; @@ -1923,7 +1777,6 @@ void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engi } else { // Xft has real trouble drawing the glyphs on their own. // Drawing them as one string increases performance significantly. -#ifdef QT_XFT2 // #### we should use a different method anyways on Xft2 FT_UInt g[64]; int gl = 0; @@ -1946,29 +1799,6 @@ void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engi gl += toDraw; x += adv; } -#else - XftChar16 g[64]; - int gl = 0; - while (gl < si->num_glyphs) { - int toDraw = TQMIN(64, si->num_glyphs-gl); - int adv = 0; - if ( si->analysis.bidiLevel % 2 ) { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[si->num_glyphs-1-(gl+i)]; - adv += advances[si->num_glyphs-1-(gl+i)]; - } - } else { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[gl+i]; - adv += advances[gl+i]; - } - } - if (x + adv < SHRT_MAX && x > SHRT_MIN) - XftDrawString16( draw, &col, fnt, x, y, g, toDraw ); - gl += toDraw; - x += adv; - } -#endif // QT_XFT2 } #ifdef FONTENGINE_DEBUG @@ -2166,7 +1996,6 @@ bool TQFontEngineXft::canRender( const TQChar *string, int len ) { bool allExist = TRUE; -#ifdef QT_XFT2 if (_cmap != -1) { for ( int i = 0; i < len; i++ ) { if (!XftCharExists(0, _font, string[i].unicode()) @@ -2183,25 +2012,6 @@ bool TQFontEngineXft::canRender( const TQChar *string, int len ) } } } -#else - glyph_t glyphs[256]; - int nglyphs = 255; - glyph_t *g = glyphs; - if ( stringToCMap( string, len, g, 0, &nglyphs, FALSE ) == OutOfMemory ) { - g = (glyph_t *)malloc( nglyphs*sizeof(glyph_t) ); - stringToCMap( string, len, g, 0, &nglyphs, FALSE ); - } - - for ( int i = 0; i < nglyphs; i++ ) { - if ( !XftGlyphExists(TQPaintDevice::x11AppDisplay(), _font, g[i]) ) { - allExist = FALSE; - break; - } - } - - if ( g != glyphs ) - free( g ); -#endif // QT_XFT2 return allExist; } |