diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-01-10 13:17:31 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-01-12 11:39:54 +0900 |
commit | 1c9111b3795a3b87254cbac172dcc565c7f76a57 (patch) | |
tree | 4989457372b878ec193198dc9c0501baef7f930f | |
parent | c147c9001b60295bdd731f95d805460c8973621b (diff) | |
download | tqt3-1c9111b3795a3b87254cbac172dcc565c7f76a57.tar.gz tqt3-1c9111b3795a3b87254cbac172dcc565c7f76a57.zip |
Drop code for obsolete FreeType 1
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit ccd304b2a6415d8b747d04b3a47736d1e6f45717)
-rwxr-xr-x | config.tests/x11/xfreetype.test | 25 | ||||
-rw-r--r-- | src/kernel/qapplication_x11.cpp | 7 | ||||
-rw-r--r-- | src/kernel/qfont_x11.cpp | 19 | ||||
-rw-r--r-- | src/kernel/qfontdatabase.cpp | 4 | ||||
-rw-r--r-- | src/kernel/qfontdatabase_x11.cpp | 290 | ||||
-rw-r--r-- | src/kernel/qfontengine_x11.cpp | 190 | ||||
-rw-r--r-- | src/kernel/qpainter_x11.cpp | 8 | ||||
-rw-r--r-- | src/kernel/qpixmap_x11.cpp | 7 | ||||
-rw-r--r-- | src/kernel/qt_x11.pri | 1 | ||||
-rw-r--r-- | src/kernel/qt_x11_p.h | 11 | ||||
-rw-r--r-- | src/kernel/qtaddons_x11.cpp | 144 | ||||
-rw-r--r-- | src/opengl/qgl_x11.cpp | 6 |
12 files changed, 2 insertions, 710 deletions
diff --git a/config.tests/x11/xfreetype.test b/config.tests/x11/xfreetype.test index d4cb4ba17..dbe610649 100755 --- a/config.tests/x11/xfreetype.test +++ b/config.tests/x11/xfreetype.test @@ -1,7 +1,6 @@ #!/bin/sh XFT=yes -XFT2=no XFT2_HEADER=no XCONFIG=$1/qmake.conf VERBOSE=$2 @@ -88,29 +87,7 @@ if [ "$XFT" = "yes" ]; then XFT_MINOR=`grep XFT_MINOR $XFT_H | head -n 1 | awk '{ print \$3 }'` XFT_REVISION=`grep XFT_REVISION $XFT_H | head -n 1 | awk '{ print \$3 }'` [ "$VERBOSE" = "yes" ] && echo " Found Xft version $XFT_MAJOR.$XFT_MINOR.$XFT_REVISION" - if [ "$XFT_MAJOR" = "2" ]; then - XFT2=yes LIBXFT="$LIBXFT -lfontconfig" - fi -fi - -# find XftFreetype.h if using Xft1 -if [ "$XFT" = "yes" ] && [ "$XFT2" = "no" ]; then - INC="X11/Xft/XftFreetype.h" - XDIRS=`sed -n -e '/^QMAKE_INCDIR_X11[ ]*=/ { s/[^=]*=[ ]*//; s/-I/ /g; p; }' $XCONFIG` - INCDIRS="$IN_INCDIRS $XDIRS /usr/include /include" - F= - for INCDIR in $INCDIRS; do - if [ -f $INCDIR/$INC ]; then - F=yes - [ "$VERBOSE" = "yes" ] && echo " Found $INC in $INCDIR" - break - fi - done - if [ -z "$F" ]; then - XFT=no - [ "$VERBOSE" = "yes" ] && echo " Could not find $INC anywhere in $INCDIRS" - fi fi # check for freetype2 headers @@ -150,7 +127,7 @@ if [ "$XFT" = "yes" ]; then fi # check for fontconfig headers when using Xft2 -if [ "$XFT" = "yes" ] && [ "$XFT2" = "yes" ]; then +if [ "$XFT" = "yes" ]; then INC="fontconfig/fontconfig.h" XDIRS=`sed -n -e '/^QMAKE_INCDIR_X11[ ]*=/ { s/[^=]*=[ ]*//; s/-I/ /g; p; }' $XCONFIG` LDIRS=`sed -n -e '/^QMAKE_INCDIR[ ]*=/ { s/[^=]*=[ ]*//; s/-I/ /g; p; }' $XCONFIG` diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 0148f8760..e0c95a6e0 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -2135,12 +2135,7 @@ void tqt_init_internal( int *argcptr, char **argv, #if !defined(TQT_NO_XFTFREETYPE) // defined in qfont_x11.cpp extern bool tqt_has_xft; -#ifndef QT_XFT2 - if (!tqt_use_xrender) - tqt_has_xft = FALSE; - else -#endif - tqt_has_xft = XftInit(0) && XftInitFtLibrary(); + tqt_has_xft = XftInit(0) && XftInitFtLibrary(); if (tqt_has_xft) { char *dpi_str = XGetDefault(appDpy, "Xft", "dpi"); diff --git a/src/kernel/qfont_x11.cpp b/src/kernel/qfont_x11.cpp index 3cd207c65..c58f8aa6c 100644 --- a/src/kernel/qfont_x11.cpp +++ b/src/kernel/qfont_x11.cpp @@ -393,25 +393,6 @@ void TQFontPrivate::load( TQFont::Script script ) for ( ; it != end; ++it ) subs_list += TQFont::substitutes( *it ); family_list += subs_list; - -#ifndef QT_XFT2 - // with Xft2, we want to use fontconfig to determine better fallbacks, - // otherwise we might run into trouble with default fonts as "serif" - - // append the default fallback font for the specified script - TQString fallback = qt_fallback_font_family( script ); - if ( ! fallback.isEmpty() && ! family_list.contains( fallback ) ) - family_list << fallback; - - // add the default family - TQString defaultFamily = TQApplication::font().family(); - if ( ! family_list.contains( defaultFamily ) ) - family_list << defaultFamily; - - // add TQFont::defaultFamily() to the list, for compatibility with - // previous versions - family_list << TQApplication::font().defaultFamily(); -#endif // QT_XFT2 } // null family means find the first font matching the specified script diff --git a/src/kernel/qfontdatabase.cpp b/src/kernel/qfontdatabase.cpp index 152b6f250..83702d308 100644 --- a/src/kernel/qfontdatabase.cpp +++ b/src/kernel/qfontdatabase.cpp @@ -998,7 +998,6 @@ TQFontDatabase::findFont( TQFont::Script script, const TQFontPrivate *fp, request.weight, request.italic, request.stretch, request.pixelSize, pitch ); bool usesFontConfig = FALSE; -#ifdef QT_XFT2 if (family_name.isEmpty() || family_name == "Sans Serif" || family_name == "Serif" @@ -1007,7 +1006,6 @@ TQFontDatabase::findFont( TQFont::Script script, const TQFontPrivate *fp, usesFontConfig = (fe != 0); } if (!fe) -#endif { TQtFontFamily *best_family = 0; TQtFontFoundry *best_foundry = 0; @@ -1067,11 +1065,9 @@ TQFontDatabase::findFont( TQFont::Script script, const TQFontPrivate *fp, } else if (try_family->scripts[TQFont::UnknownScript] & TQtFontFamily::Supported) { // try with the unknown script (for a symbol font) override_script = TQFont::UnknownScript; -#ifndef QT_XFT2 } else if (try_family->scripts[TQFont::Unicode] & TQtFontFamily::Supported) { // try with the unicode script instead override_script = TQFont::Unicode; -#endif } else { // family not supported by unicode/unknown scripts continue; diff --git a/src/kernel/qfontdatabase_x11.cpp b/src/kernel/qfontdatabase_x11.cpp index c449b8961..603623d75 100644 --- a/src/kernel/qfontdatabase_x11.cpp +++ b/src/kernel/qfontdatabase_x11.cpp @@ -58,12 +58,6 @@ #include FT_FREETYPE_H #endif -#ifndef QT_XFT2 -#define FcBool Bool -#define FcTrue True -#define FcFalse False -#endif - #ifdef TQFONTDATABASE_DEBUG # define FD_DEBUG tqDebug #else @@ -721,9 +715,7 @@ static void loadXlfds( const char *reqFamily, int encoding_id ) if ( fontFamily && fontFamily->xlfdLoaded ) return; -#ifdef QT_XFT2 if ( !tqt_has_xft ) { -#endif // QT_XFT2 int fontCount; // force the X server to give us XLFDs TQCString xlfd_pattern = "-*-"; @@ -825,10 +817,7 @@ static void loadXlfds( const char *reqFamily, int encoding_id ) } XFreeFontNames( fontList ); - -#ifdef QT_XFT2 } -#endif // QT_XFT2 } #ifndef TQT_NO_XFTFREETYPE @@ -852,7 +841,6 @@ static void loadXft() if (!tqt_has_xft) return; -#ifdef QT_XFT2 struct XftDefaultFont { const char *qtname; const char *rawname; @@ -893,7 +881,6 @@ static void loadXft() } ++f; } -#endif } #ifdef XFT_MATRIX @@ -968,16 +955,13 @@ static bool loadXftFont( FcPattern* font ) XftPatternGetInteger (font, XFT_SPACING, 0, &spacing_value); XftPatternGetString (font, XFT_FILE, 0, &file_value); XftPatternGetInteger (font, XFT_INDEX, 0, &index_value); -#ifdef QT_XFT2 FcPatternGetBool(font, FC_SCALABLE, 0, &scalable); foundry_value = 0; XftPatternGetString(font, FC_FOUNDRY, 0, &foundry_value); -#endif TQtFontFamily *family = db->family( familyName, TRUE ); family->rawName = rawName; family->hasXft = TRUE; -#ifdef QT_XFT2 FcCharSet *charset = 0; FcResult res = FcPatternGetCharSet(font, FC_CHARSET, 0, &charset); if (res == FcResultMatch && FcCharSetCount(charset) > 1) { @@ -1003,7 +987,6 @@ static bool loadXftFont( FcPattern* font ) family->scripts[i] |= TQtFontFamily::UnSupported_Xft; family->scripts[TQFont::UnknownScript] = TQtFontFamily::Supported; } -#endif // QT_XFT2 TQCString file = (file_value ? file_value : ""); family->fontFilename = file; @@ -1013,7 +996,6 @@ static bool loadXftFont( FcPattern* font ) styleKey.italic = (slant_value == XFT_SLANT_ITALIC); styleKey.oblique = (slant_value == XFT_SLANT_OBLIQUE); styleKey.weight = getXftWeight( weight_value ); -#ifdef QT_XFT2 if (!scalable) { int width = 100; #if FC_VERSION >= 20193 @@ -1021,7 +1003,6 @@ static bool loadXftFont( FcPattern* font ) #endif styleKey.stretch = width; } -#endif TQtFontFoundry *foundry = family->foundry( foundry_value ? TQString::fromUtf8(foundry_value) : TQString::null, TRUE ); @@ -1035,13 +1016,11 @@ static bool loadXftFont( FcPattern* font ) style->smoothScalable = TRUE; size = style->pixelSize( SMOOTH_SCALABLE, TRUE ); } -#ifdef QT_XFT2 else { double pixel_size = 0; XftPatternGetDouble (font, FC_PIXEL_SIZE, 0, &pixel_size); size = style->pixelSize( (int)pixel_size, TRUE ); } -#endif TQtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE ); enc->pitch = ( spacing_value >= XFT_CHARCELL ? 'c' : ( spacing_value >= XFT_MONO ? 'm' : 'p' ) ); @@ -1051,236 +1030,6 @@ static bool loadXftFont( FcPattern* font ) return true; } -#ifndef QT_XFT2 - -#define MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (TQ_UINT32)_x1 << 24 ) | \ - ( (TQ_UINT32)_x2 << 16 ) | \ - ( (TQ_UINT32)_x3 << 8 ) | \ - (TQ_UINT32)_x4 ) - -#ifdef _POSIX_MAPPED_FILES -static inline TQ_UINT32 getUInt(unsigned char *p) -{ - TQ_UINT32 val; - val = *p++ << 24; - val |= *p++ << 16; - val |= *p++ << 8; - val |= *p; - - return val; -} - -static inline TQ_UINT16 getUShort(unsigned char *p) -{ - TQ_UINT16 val; - val = *p++ << 8; - val |= *p; - - return val; -} - -static inline void tag_to_string( char *string, TQ_UINT32 tag ) -{ - string[0] = (tag >> 24)&0xff; - string[1] = (tag >> 16)&0xff; - string[2] = (tag >> 8)&0xff; - string[3] = tag&0xff; - string[4] = 0; -} - -static TQ_UINT16 getGlyphIndex( unsigned char *table, TQ_UINT16 format, unsigned short unicode ) -{ - if ( format == 0 ) { - if ( unicode < 256 ) - return (int) *(table+6+unicode); - } else if ( format == 2 ) { - tqWarning("format 2 encoding table for Unicode, not implemented!"); - } else if ( format == 4 ) { - TQ_UINT16 segCountX2 = getUShort( table + 6 ); - unsigned char *ends = table + 14; - TQ_UINT16 endIndex = 0; - int i = 0; - for ( ; i < segCountX2/2 && (endIndex = getUShort( ends + 2*i )) < unicode; i++ ); - - unsigned char *idx = ends + segCountX2 + 2 + 2*i; - TQ_UINT16 startIndex = getUShort( idx ); - - if ( startIndex > unicode ) - return 0; - - idx += segCountX2; - TQ_INT16 idDelta = (TQ_INT16)getUShort( idx ); - idx += segCountX2; - TQ_UINT16 idRangeoffset_t = (TQ_UINT16)getUShort( idx ); - - TQ_UINT16 glyphIndex; - if ( idRangeoffset_t ) { - TQ_UINT16 id = getUShort( idRangeoffset_t + 2*(unicode - startIndex) + idx); - if ( id ) - glyphIndex = ( idDelta + id ) % 0x10000; - else - glyphIndex = 0; - } else { - glyphIndex = (idDelta + unicode) % 0x10000; - } - return glyphIndex; - } - - return 0; -} -#endif // _POSIX_MAPPED_FILES - -static inline void checkXftCoverage( TQtFontFamily *family ) -{ -#ifdef _POSIX_MAPPED_FILES - TQCString ext = family->fontFilename.mid( family->fontFilename.findRev( '.' ) ).lower(); - if ( family->fontFileIndex == 0 && ( ext == ".ttf" || ext == ".otf" ) ) { - void *map; - // tqDebug("using own ttf code coverage checking of '%s'!", family->name.latin1() ); - int fd = open( family->fontFilename.data(), O_RDONLY ); - size_t pagesize = getpagesize(); - off_t offset = 0; - size_t length = (8192 / pagesize + 1) * pagesize; - - if ( fd == -1 ) - goto xftCheck; - { - if ( (map = mmap( 0, length, PROT_READ, MAP_SHARED, fd, offset ) ) == MAP_FAILED ) - goto error; - - unsigned char *ttf = (unsigned char *)map; - TQ_UINT32 version = getUInt( ttf ); - if ( version != 0x00010000 ) { - // tqDebug("file has wrong version %x", version ); - goto error1; - } - TQ_UINT16 numTables = getUShort( ttf+4 ); - - unsigned char *table_dir = ttf + 12; - TQ_UINT32 cmap_offset = 0; - TQ_UINT32 cmap_length = 0; - for ( int n = 0; n < numTables; n++ ) { - TQ_UINT32 tag = getUInt( table_dir + 16*n ); - if ( tag == MAKE_TAG( 'c', 'm', 'a', 'p' ) ) { - cmap_offset = getUInt( table_dir + 16*n + 8 ); - cmap_length = getUInt( table_dir + 16*n + 12 ); - break; - } - } - if ( !cmap_offset ) { - // tqDebug("no cmap found" ); - goto error1; - } - - if ( cmap_offset + cmap_length > length ) { - munmap( map, length ); - offset = cmap_offset / pagesize * pagesize; - cmap_offset -= offset; - length = (cmap_offset + cmap_length); - if ( (map = mmap( 0, length, PROT_READ, MAP_SHARED, fd, offset ) ) == MAP_FAILED ) - goto error; - } - - unsigned char *cmap = ((unsigned char *)map) + cmap_offset; - - version = getUShort( cmap ); - if ( version != 0 ) { - // tqDebug("wrong cmap version" ); - goto error1; - } - numTables = getUShort( cmap + 2 ); - unsigned char *unicode_table = 0; - bool symbol_table = TRUE; - for ( int n = 0; n < numTables; n++ ) { - TQ_UINT32 version = getUInt( cmap + 4 + 8*n ); - // accept both symbol and Unicode encodings. prefer unicode. - if ( version == 0x00030001 || version == 0x00030000 ) { - unicode_table = cmap + getUInt( cmap + 4 + 8*n + 4 ); - if ( version == 0x00030001 ) { - symbol_table = FALSE; - break; - } - } - } - - if ( !unicode_table ) { - // tqDebug("no unicode table found" ); - goto error1; - } - - TQ_UINT16 format = getUShort( unicode_table ); - if ( format != 4 ) - goto error1; - - if (symbol_table) { - // we set UnknownScript to supported for symbol fonts. It makes no sense to merge these - // with other ones, as they are special in a way. - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - family->scripts[TQFont::UnknownScript] = TQtFontFamily::Supported; - } else { - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - - bool supported = sample_chars[i][0]; - for (int j = 0; sample_chars[i][j]; ++j) { - if (!getGlyphIndex(unicode_table, format, sample_chars[i][j])) { - supported=false; - break; - } - } - if ( supported ){ - // tqDebug("font can render script %d", i ); - family->scripts[i] = TQtFontFamily::Supported; - } else { - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - } - } - } - family->xftScriptCheck = TRUE; - } - error1: - munmap( map, length ); - error: - close( fd ); - if ( family->xftScriptCheck ) - return; - } - xftCheck: -#endif // _POSIX_MAPPED_FILES - - FD_DEBUG("using Freetype for checking of '%s'", family->name.latin1() ); - - FT_Library ft_lib; - FT_Error error = FT_Init_FreeType( &ft_lib ); - if ( error ) return; - FT_Face face; - error = FT_New_Face( ft_lib, family->fontFilename, family->fontFileIndex, &face ); - if ( error ) return; - - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - bool supported = sample_chars[i][j]; - for (int j = 0; sample_chars[i][j]; ++j){ - if (!FT_Get_Char_Index(face, sample_chars[i][j])) { - supported=false; - break; - } - } - if ( supported ){ - FD_DEBUG("font can render char %04x, %04x script %d '%s'", - ch.unicode(), FT_Get_Char_Index ( face, ch.unicode() ), - i, TQFontDatabase::scriptName( (TQFont::Script)i ).latin1() ); - - family->scripts[i] = TQtFontFamily::Supported; - } else { - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - } - } - FT_Done_Face( face ); - FT_Done_FreeType( ft_lib ); - family->xftScriptCheck = TRUE; -} -#endif // QT_XFT2 #endif // TQT_NO_XFTFREETYPE static void load( const TQString &family = TQString::null, int script = -1 ) @@ -1301,21 +1050,17 @@ static void load( const TQString &family = TQString::null, int script = -1 ) (const char *)0, XFT_FAMILY, XFT_WEIGHT, XFT_SLANT, XFT_SPACING, XFT_FILE, XFT_INDEX, -#ifdef QT_XFT2 FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, #if FC_VERSION >= 20193 FC_WIDTH, #endif -#endif // QT_XFT2 (const char *)0); for (int i = 0; i < fonts->nfont; i++) loadXftFont( fonts->fonts[i] ); XftFontSetDestroy (fonts); } -#ifdef QT_XFT2 if (tqt_has_xft) return; -#endif #endif // TQT_NO_XFTFREETYPE if ( script == -1 ) loadXlfds( 0, -1 ); @@ -1340,12 +1085,10 @@ static void load( const TQString &family = TQString::null, int script = -1 ) (const char *)0, XFT_FAMILY, XFT_WEIGHT, XFT_SLANT, XFT_SPACING, XFT_FILE, XFT_INDEX, -#ifdef QT_XFT2 FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, #if FC_VERSION >= 20193 FC_WIDTH, #endif -#endif // QT_XFT2 (const char *)0); for (int i = 0; i < fonts->nfont; i++) loadXftFont( fonts->fonts[i] ); @@ -1355,16 +1098,8 @@ static void load( const TQString &family = TQString::null, int script = -1 ) goto redo; } f->fullyLoaded = TRUE; -#ifdef QT_XFT2 return; -#endif } -#ifndef QT_XFT2 - // need to check Xft coverage - if ( f->hasXft && !f->xftScriptCheck ) { - checkXftCoverage( f ); - } -#endif #endif // TQT_NO_XFTFREETYPE // could reduce this further with some more magic: // would need to remember the encodings loaded for the family. @@ -1389,10 +1124,6 @@ static void initializeDb() db = new TQFontDatabasePrivate; qfontdatabase_cleanup.set(&db); -#ifndef QT_XFT2 - memset( encodingLoaded, FALSE, sizeof( encodingLoaded ) ); -#endif - TQTime t; t.start(); @@ -1405,11 +1136,6 @@ static void initializeDb() #ifndef TQT_NO_XFTFREETYPE for ( int i = 0; i < db->count; i++ ) { -#ifndef QT_XFT2 - checkXftCoverage( db->families[i] ); - FD_DEBUG("TQFontDatabase: xft coverage check: %d ms", t.elapsed() ); -#endif // QT_XFT2 - #ifdef XFT_MATRIX checkXftMatrix( db->families[i] ); #endif // XFT_MATRIX @@ -1418,9 +1144,7 @@ static void initializeDb() #ifdef TQFONTDATABASE_DEBUG -#ifdef QT_XFT2 if (!tqt_has_xft) -#endif // load everything at startup in debug mode. loadXlfds( 0, -1 ); @@ -1520,7 +1244,6 @@ static double addPatternProps(XftPattern *pattern, const TQtFontStyle::Key &key, size_value = MAXFONTSIZE_XFT; } -#ifdef QT_XFT2 /* 2006-12-28 If QT is not compiled against xft1, there is no need for the workaround above (confirmed). Thus, in addition, add @@ -1530,12 +1253,10 @@ static double addPatternProps(XftPattern *pattern, const TQtFontStyle::Key &key, */ XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, size_value); XftPatternAddDouble(pattern, XFT_DPI, dpi); -#endif size_value = size_value*72./dpi; XftPatternAddDouble( pattern, XFT_SIZE, size_value ); #ifdef XFT_MATRIX -# ifdef QT_XFT2 if (!smoothScalable) { # if FC_VERSION >= 20193 int stretch = request.stretch; @@ -1544,7 +1265,6 @@ static double addPatternProps(XftPattern *pattern, const TQtFontStyle::Key &key, XftPatternAddInteger(pattern, FC_WIDTH, stretch); # endif } else -# endif if ( ( request.stretch > 0 && request.stretch != 100 ) || ( key.oblique && fakeOblique ) ) { XftMatrix matrix; @@ -1602,7 +1322,6 @@ TQFontEngine *loadEngine( TQFont::Script script, if ( !pattern ) return 0; bool symbol = (family->scripts[TQFont::UnknownScript] == TQtFontFamily::Supported); -# ifdef QT_XFT2 if (!symbol && script != TQFont::Unicode) { FcCharSet *cs = FcCharSetCreate(); for ( int j=0; sample_chars[script][j]; j++ ) @@ -1613,9 +1332,6 @@ TQFontEngine *loadEngine( TQFont::Script script, FcPatternAddCharSet(pattern, FC_CHARSET, cs); FcCharSetDestroy(cs); } -# else - XftPatternAddString( pattern, XFT_ENCODING, symbol ? "adobe-fontspecific" : "iso10646-1"); -# endif // QT_XFT2 if ( !foundry->name.isEmpty() ) XftPatternAddString( pattern, XFT_FOUNDRY, @@ -1636,7 +1352,6 @@ TQFontEngine *loadEngine( TQFont::Script script, XftResult res; XftPattern *result = XftFontMatch( TQPaintDevice::x11AppDisplay(), fp->screen, pattern, &res ); -#ifdef QT_XFT2 if (result && script == TQFont::Latin) { // since we added the Euro char on top, check we actually got the family // we requested. If we didn't get it correctly, remove the Euro from the pattern @@ -1653,7 +1368,6 @@ TQFontEngine *loadEngine( TQFont::Script script, result = XftFontMatch( TQPaintDevice::x11AppDisplay(), fp->screen, pattern, &res ); } } -#endif XftPatternDestroy(pattern); if (!result) return 0; @@ -1752,8 +1466,6 @@ TQFontEngine *loadEngine( TQFont::Script script, } -#ifdef QT_XFT2 - static void parseFontName(const TQString &name, TQString &foundry, TQString &family) { if ( name.contains('[') && name.contains(']')) { @@ -2027,5 +1739,3 @@ static TQFontEngine *loadFontConfigFont(const TQFontPrivate *fp, const TQFontDef return fe; } - -#endif 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; } diff --git a/src/kernel/qpainter_x11.cpp b/src/kernel/qpainter_x11.cpp index 82d491cb2..d4c970ad3 100644 --- a/src/kernel/qpainter_x11.cpp +++ b/src/kernel/qpainter_x11.cpp @@ -170,15 +170,7 @@ static inline void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, TQt::HANDLE d #ifndef TQT_NO_XFTFREETYPE if (draw) { -# ifdef QT_XFT2 XftDrawSetClip((XftDraw *) draw, None); -# else - // stupid Xft1 - Picture pict = XftDrawPicture((XftDraw *) draw); - XRenderPictureAttributes pattr; - pattr.clip_mask = None; - XRenderChangePicture(dpy, pict, CPClipMask, &pattr); -# endif // QT_XFT2 } #else Q_UNUSED(draw); diff --git a/src/kernel/qpixmap_x11.cpp b/src/kernel/qpixmap_x11.cpp index d0bfa97a2..184cc4f16 100644 --- a/src/kernel/qpixmap_x11.cpp +++ b/src/kernel/qpixmap_x11.cpp @@ -374,13 +374,6 @@ static int defaultScreen = -1; extern bool tqt_use_xrender; // defined in qapplication_x11.cpp extern bool tqt_has_xft; // defined in qfont_x11.cpp -#ifndef TQT_NO_XFTFREETYPE -#ifndef QT_XFT2 -// Xft1 doesn't have XftDrawCreateAlpha, so we fake it in qtaddons_x11.cpp -extern "C" XftDraw *XftDrawCreateAlpha( Display *, TQt::HANDLE, int ); -#endif // QT_XFT2 -#endif // TQT_NO_XFTFREETYPE - /***************************************************************************** TQPixmap member functions *****************************************************************************/ diff --git a/src/kernel/qt_x11.pri b/src/kernel/qt_x11.pri index c81055eb3..cd8d856a5 100644 --- a/src/kernel/qt_x11.pri +++ b/src/kernel/qt_x11.pri @@ -8,7 +8,6 @@ unix { !xkb:DEFINES += TQT_NO_XKB xft2header:DEFINES+=QT_USE_XFT2_HEADER - SOURCES += $$KERNEL_CPP/qtaddons_x11.cpp PRECOMPILED_HEADER = kernel/qt_pch.h SOURCES += $$KERNEL_CPP/tqttdeintegration_x11.cpp diff --git a/src/kernel/qt_x11_p.h b/src/kernel/qt_x11_p.h index a94300a24..8c1f043a5 100644 --- a/src/kernel/qt_x11_p.h +++ b/src/kernel/qt_x11_p.h @@ -157,17 +157,6 @@ extern "C" { # else # include <X11/Xft/Xft.h> # endif // QT_USE_XFT2_HEADER -# if defined(XFT_VERSION) && XFT_VERSION >= 20000 -# define QT_XFT2 -# else -# include <X11/Xft/XftFreetype.h> -// Xft1 doesn't have these functions, so we implement them in qtaddons_x11.cpp -extern "C" { - TQt::HANDLE XftDrawPicture( XftDraw * ); - void XftDrawSetClipRectangles(XftDraw *, int, int, XRectangle *, int); - void XftDrawSetSubwindowMode(XftDraw *, int); -} -# endif // XFT_VERSION # endif // TQT_NO_XFTFREETYPE #else // make sure TQT_NO_XFTFREETYPE is defined if TQT_NO_XRENDER is defined diff --git a/src/kernel/qtaddons_x11.cpp b/src/kernel/qtaddons_x11.cpp deleted file mode 100644 index ad1ea7e00..000000000 --- a/src/kernel/qtaddons_x11.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * $XFree86: xc/lib/Xft/xftname.c,v 1.10 2001/03/30 18:50:18 keithp Exp $ - * - * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "qt_x11_p.h" - -#if !defined(TQT_NO_XFTFREETYPE) && !defined(QT_XFT2) - -#include <X11/Xft/Xft.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -extern bool tqt_use_xrender; // defined in qapplication_x11.cpp - -extern "C" { - -#define XFT_DRAW_N_SRC 2 - -struct _XftDraw { - Display *dpy; - Drawable drawable; - Visual *visual; - Colormap colormap; - Region clip; - Bool core_set; - Bool render_set; - Bool render_able; - struct { - Picture pict; - struct { - Picture pict; - XRenderColor color; - } src[XFT_DRAW_N_SRC]; - } render; - struct { - GC draw_gc; - unsigned long fg; - Font font; - } core; -}; - -Picture XftDrawPicture( XftDraw *draw ) -{ - if ( ! draw ) return 0; - if ( ! draw->render_set ) { - // force the RENDER Picture to be created... - XftColor color; - color.color.red = color.color.green = color.color.blue = color.color.alpha = - color.pixel = 0; - XftDrawRect( draw, &color, -100, -100, 1, 1 ); - } - return draw->render.pict; -} - -XftDraw *XftDrawCreateAlpha( Display *display, - Pixmap pixmap, - int depth ) -{ - // taken from Xft 1 sources, see copyright above - XftDraw *draw; - - draw = (XftDraw *) malloc (sizeof (XftDraw)); - if (!draw) - return 0; - draw->dpy = display; - draw->drawable = pixmap; - draw->visual = 0; - draw->colormap = 0; - draw->core_set = False; - draw->clip = 0; - - // TQt addition - go ahead and create the render picture now - draw->render_set = True; - draw->render_able = False; - - if ( tqt_use_xrender ) { - draw->render_able = True; - - XRenderPictFormat *format = 0; - XRenderPictFormat req; - unsigned long mask = PictFormatType | PictFormatDepth | PictFormatAlphaMask; - req.type = PictTypeDirect; - req.depth = depth; - req.direct.alphaMask = 0xff; - format = XRenderFindFormat(draw->dpy, mask, &req, 0); - if (format) { - draw->render.pict = - XRenderCreatePicture(draw->dpy, draw->drawable, format, 0, 0); - } - - // to keep Xft from trying to free zero pixmaps/pictures, we need to create - // 2 more pictures (that are identical to draw->render.pict) :/ - draw->render.src[0].pict = - XRenderCreatePicture( draw->dpy, draw->drawable, format, 0, 0 ); - draw->render.src[1].pict = - XRenderCreatePicture( draw->dpy, draw->drawable, format, 0, 0 ); - } - - return draw; -} - -void XftDrawSetClipRectangles(XftDraw *draw, int xoff, int yoff, XRectangle *rects, int count) -{ - if (!draw) return; - - Picture pict = XftDrawPicture(draw); - XRenderSetPictureClipRectangles(draw->dpy, pict, xoff, yoff, rects, count); -} - -void XftDrawSetSubwindowMode(XftDraw *draw, int mode) -{ - if (!draw) return; - - Picture pict = XftDrawPicture(draw); - XRenderPictureAttributes pattr; - pattr.subwindow_mode = mode; - XRenderChangePicture(draw->dpy, pict, CPSubwindowMode, &pattr); -} - -} // extern "C" - -#endif // !TQT_NO_XFTFREETYPE && !QT_XFT2 diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 51daa176b..724e999e4 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -867,11 +867,7 @@ void qgl_use_font(TQFontEngineXft *engine, int first, int count, int listBase) #if 0 // disable antialias support for now XftPatternGetBool(engine->pattern(), XFT_ANTIALIAS, 0, &antialiased); #endif -#ifdef QT_XFT2 FT_Face face = XftLockFace(engine->font()); -#else - FT_Face face = engine->face(); -#endif // start generating font glyphs for (int i = first; i < count; ++i) { int list = listBase + i; @@ -934,9 +930,7 @@ void qgl_use_font(TQFontEngineXft *engine, int first, int count, int listBase) antialiased ? delete[] aa_glyph : delete[] ua_glyph; } -#ifdef QT_XFT2 XftUnlockFace(engine->font()); -#endif // restore pixel unpack settings glPixelStorei(GL_UNPACK_SWAP_BYTES, gl_swapbytes); |