summaryrefslogtreecommitdiffstats
path: root/src/kernel/qfontdatabase_x11.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-01-10 13:17:31 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-01-12 11:39:54 +0900
commit1c9111b3795a3b87254cbac172dcc565c7f76a57 (patch)
tree4989457372b878ec193198dc9c0501baef7f930f /src/kernel/qfontdatabase_x11.cpp
parentc147c9001b60295bdd731f95d805460c8973621b (diff)
downloadtqt3-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)
Diffstat (limited to 'src/kernel/qfontdatabase_x11.cpp')
-rw-r--r--src/kernel/qfontdatabase_x11.cpp290
1 files changed, 0 insertions, 290 deletions
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