diff -rc qt-x11-free-3.3.3/include/private/qfontdata_p.h qt-x11-free-3.3.3/include/private/qfontdata_p.h
*** qt-x11-free-3.3.3/include/private/qfontdata_p.h	Thu Aug  5 23:42:06 2004
--- qt-x11-free-3.3.3/include/private/qfontdata_p.h	Tue Dec 21 02:20:54 2004
***************
*** 150,155 ****
--- 150,160 ----
  #if defined(Q_WS_X11) || defined(Q_WS_WIN)
  	if ( ! engineData || ! engineData->engines[script] )
  	    ((QFontPrivate *) this)->load( script );
+ #ifdef Q_WS_X11
+ 	if ( script == QFont::Unicode &&
+ 	     engineData->engines[script] == (QFontEngine *)-1 )
+ 	    return engineForScript( QFontPrivate::globalScript ); // NoScript or Han
+ #endif // Q_WS_X11
  	return engineData->engines[script];
  #else
          if ( ! engineData || ! engineData->engine )
***************
*** 158,163 ****
--- 163,173 ----
  #endif // Q_WS_X11 || Q_WS_WIN
      }
  
+ #ifdef Q_WS_X11
+     static QFont::Script globalScript;
+     QFont::Script checkGlobalScript( QFont::Script script, const QChar &ch );
+ #endif // Q_WS_X11
+ 
      QFontDef request;
      QFontEngineData *engineData;
      QPaintDevice *paintdevice;
diff -rc qt-x11-free-3.3.3/include/private/qunicodetables_p.h qt-x11-free-3.3.3/include/private/qunicodetables_p.h
*** qt-x11-free-3.3.3/include/private/qunicodetables_p.h	Thu Aug  5 23:41:57 2004
--- qt-x11-free-3.3.3/include/private/qunicodetables_p.h	Tue Dec 21 02:22:07 2004
***************
*** 50,55 ****
--- 50,56 ----
  
  #ifndef QT_H
  #include "qstring.h"
+ #include "private/qfontdata_p.h"
  #endif // QT_H
  
  #ifdef QT_NO_UNICODETABLES
***************
*** 227,234 ****
  #endif
  }
  
! inline int scriptForChar( ushort uc )
  {
      unsigned char script = QUnicodeTables::scriptTable[(uc>>8)];
      if ( script >= QUnicodeTables::SCRIPTS_INDIC ) {
  	if ( script == QUnicodeTables::SCRIPTS_INDIC ) {
--- 228,236 ----
  #endif
  }
  
! inline int scriptForChar( const QChar &ch, QFontPrivate *fnt = 0 )
  {
+     unsigned short uc = ch.unicode();
      unsigned char script = QUnicodeTables::scriptTable[(uc>>8)];
      if ( script >= QUnicodeTables::SCRIPTS_INDIC ) {
  	if ( script == QUnicodeTables::SCRIPTS_INDIC ) {
***************
*** 242,263 ****
  	    script = QUnicodeTables::otherScripts[index];
  	}
      }
-     return script;
- }
  
  #ifdef Q_WS_X11
! #define SCRIPT_FOR_CHAR( script, c ) 	\
! do { 						\
!     unsigned short _uc = (c).unicode(); 		\
!     if ( _uc < 0x100 ) {				\
! 	script = QFont::Latin;		\
!     } else { 					\
!         script = (QFont::Script)scriptForChar( _uc ); 	\
!     } 						\
! } while( FALSE )
  #else
! #define SCRIPT_FOR_CHAR( script, c ) \
!     script = (QFont::Script)scriptForChar( (c).unicode() )
! #endif
  
  #endif
--- 244,261 ----
  	    script = QUnicodeTables::otherScripts[index];
  	}
      }
  
  #ifdef Q_WS_X11
!     if ( fnt )
!       script = fnt->checkGlobalScript( (QFont::Script)script, ch );
  #else
!     Q_UNUSED( fnt );
! #endif // Q_WS_X11
! 
!     return script;
! }
! 
! #define SCRIPT_FOR_CHAR( script, c, fnt ) \
!     script = (QFont::Script)scriptForChar( c, fnt )
  
  #endif
diff -rc qt-x11-free-3.3.3/src/kernel/qfont.cpp qt-x11-free-3.3.3/src/kernel/qfont.cpp
*** qt-x11-free-3.3.3/src/kernel/qfont.cpp	Thu Aug  5 23:42:05 2004
--- qt-x11-free-3.3.3/src/kernel/qfont.cpp	Tue Dec 21 02:20:54 2004
***************
*** 219,225 ****
  {
  #if defined(Q_WS_X11) || defined(Q_WS_WIN)
      for ( int i = 0; i < QFont::LastPrivateScript; i++ ) {
! 	if ( engines[i] )
  	    engines[i]->deref();
  	engines[i] = 0;
      }
--- 219,225 ----
  {
  #if defined(Q_WS_X11) || defined(Q_WS_WIN)
      for ( int i = 0; i < QFont::LastPrivateScript; i++ ) {
! 	if ( engines[i] && engines[i] != (QFontEngine *)-1 )
  	    engines[i]->deref();
  	engines[i] = 0;
      }
***************
*** 2145,2151 ****
  bool QFontMetrics::inFont(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
--- 2145,2151 ----
  bool QFontMetrics::inFont(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
***************
*** 2172,2178 ****
  int QFontMetrics::leftBearing(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
--- 2172,2178 ----
  int QFontMetrics::leftBearing(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
***************
*** 2206,2212 ****
  int QFontMetrics::rightBearing(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
--- 2206,2212 ----
  int QFontMetrics::rightBearing(QChar ch) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
***************
*** 2256,2262 ****
  	    width += d->engineData->widthCache[uc];
  	else if ( ::category( *ch ) != QChar::Mark_NonSpacing ) {
  	    QFont::Script script;
! 	    SCRIPT_FOR_CHAR( script, *ch );
  
  	    if (script >= QFont::Arabic && script <= QFont::Khmer)
  		break;
--- 2256,2262 ----
  	    width += d->engineData->widthCache[uc];
  	else if ( ::category( *ch ) != QChar::Mark_NonSpacing ) {
  	    QFont::Script script;
! 	    SCRIPT_FOR_CHAR( script, *ch, d );
  
  	    if (script >= QFont::Arabic && script <= QFont::Khmer)
  		break;
***************
*** 2386,2392 ****
  QRect QFontMetrics::boundingRect( QChar ch ) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
--- 2386,2392 ----
  QRect QFontMetrics::boundingRect( QChar ch ) const
  {
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
diff -rc qt-x11-free-3.3.3/src/kernel/qfont_x11.cpp qt-x11-free-3.3.3/src/kernel/qfont_x11.cpp
*** qt-x11-free-3.3.3/src/kernel/qfont_x11.cpp	Thu Aug  5 23:42:09 2004
--- qt-x11-free-3.3.3/src/kernel/qfont_x11.cpp	Tue Dec 21 02:25:43 2004
***************
*** 56,61 ****
--- 56,62 ----
  #include "qfontdata_p.h"
  #include "qfontengine_p.h"
  #include "qtextengine_p.h"
+ #include "qscriptengine_p.h"
  
  #include "qt_x11_p.h"
  
***************
*** 169,174 ****
--- 170,176 ----
  
  
  QFont::Script QFontPrivate::defaultScript = QFont::UnknownScript;
+ QFont::Script QFontPrivate::globalScript = QFont::NoScript;
  int QFontPrivate::defaultEncodingID = -1;
  
  /*!
***************
*** 208,213 ****
--- 210,216 ----
      int mib = codec ? codec->mibEnum() : 4;
  
      // for asian locales, use the mib for the font codec instead of the locale codec
+     QFontPrivate::globalScript = QFont::Han;
      switch (mib) {
      case 38: // eucKR
  	mib = 36;
***************
*** 241,246 ****
--- 244,253 ----
      case 18: // eucJP
  	mib = 63;
  	break;
+ 
+     default:
+ 	QFontPrivate::globalScript = QFont::NoScript;
+ 	break;
      }
  
      // get the default encoding id for the locale encoding...
***************
*** 276,282 ****
  	QFontPrivate *priv = new QFontPrivate;
  
  	for ( uint i = 0; i < sample.length(); i++ ) {
! 	    SCRIPT_FOR_CHAR( tmp, *uc );
  	    uc++;
  	    if ( tmp != cs && tmp != QFont::UnknownScript ) {
  		cs = tmp;
--- 283,289 ----
  	QFontPrivate *priv = new QFontPrivate;
  
  	for ( uint i = 0; i < sample.length(); i++ ) {
! 	    SCRIPT_FOR_CHAR( tmp, *uc, 0 );
  	    uc++;
  	    if ( tmp != cs && tmp != QFont::UnknownScript ) {
  		cs = tmp;
***************
*** 364,375 ****
--- 371,394 ----
      // the cached engineData could have already loaded the engine we want
      if ( engineData->engines[script] ) return;
  
+     QFontEngine *engine_unicode = 0;
+     if ( script != QFont::Unicode && script != QFontPrivate::defaultScript ) {
+ 	if ( !engineData->engines[QFont::Unicode] )
+ 	    load( QFont::Unicode );
+ 
+ 	engine_unicode = engineData->engines[QFont::Unicode];
+ 
+ 	if ( engine_unicode == (QFontEngine *)-1 )
+ 	    engine_unicode = 0;
+     }
+ 
      // load the font
      QFontEngine *engine = 0;
      //    double scale = 1.0; // ### TODO: fix the scale calculations
  
      // list of families to try
      QStringList family_list;
+     int req_count = family_list.count();
  
      if (!req.family.isEmpty()) {
  	family_list = QStringList::split( ',', req.family );
***************
*** 377,382 ****
--- 396,404 ----
  	// append the substitute list for each family in family_list
  	QStringList subs_list;
  	QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
+     if ( script == QFont::Unicode && QFontPrivate::defaultScript != QFont::Unicode )
+ 	for ( end = family_list.begin(); req_count-- > 0; end++ );
+ 
  	for ( ; it != end; ++it )
  	    subs_list += QFont::substitutes( *it );
  	family_list += subs_list;
***************
*** 411,418 ****
  
  	engine = QFontDatabase::findFont( script, this, req );
  	if ( engine ) {
! 	    if ( engine->type() != QFontEngine::Box )
! 		break;
  
  	    if ( ! req.family.isEmpty() )
  		engine = 0;
--- 433,442 ----
  
  	engine = QFontDatabase::findFont( script, this, req );
  	if ( engine ) {
! 	    if ( engine->type() != QFontEngine::Box ) {
! 		if ( req_count-- <= 0 || engine != engine_unicode )
! 		    break;
! 	    }
  
  	    if ( ! req.family.isEmpty() )
  		engine = 0;
***************
*** 421,430 ****
--- 445,482 ----
  	}
      }
  
+     if ( script == QFont::Unicode && !engine ) {
+ 	engineData->engines[script] = (QFontEngine *)-1;
+ 	return;
+     }
+ 
      engine->ref();
      engineData->engines[script] = engine;
  }
  
+ /*! \internal
+     X11 Only: Returns a global-wide script (i.e. QFont::Unicode or QFont::Han)
+     if the fontengine for it can render a given char.
+ */
+ QFont::Script QFontPrivate::checkGlobalScript( QFont::Script script, const QChar &ch )
+ {
+     static ShapeFunction basic_shape = scriptEngines[QFont::Latin].shape;
+ 
+     if ( scriptEngines[script].shape != basic_shape )
+ 	return script;
+ 
+     QFontEngine *fe1 = engineForScript( QFont::Unicode );
+     if ( fe1 != (QFontEngine *)-1 && fe1->canRender( &ch, 1 ) ) {
+ 	script = QFont::Unicode;
+     } else if ( QFontPrivate::globalScript != QFont::NoScript ) {
+ 	QFontEngine *fe2 = engineForScript( QFontPrivate::globalScript );
+ 	if ( fe2 != fe1 && fe2->canRender( &ch, 1 ) )
+ 	    script = QFontPrivate::globalScript;
+     }
+ 
+     return script;
+ }
+ 
  /*!
      Returns TRUE if the font attributes have been changed and the font
      has to be (re)loaded; otherwise returns FALSE.
***************
*** 663,669 ****
  	return 0;
  
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
--- 715,721 ----
  	return 0;
  
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      QFontEngine *engine = d->engineForScript( script );
  #ifdef QT_CHECK_STATE
***************
*** 697,703 ****
  	return 0;
  
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch );
  
      int width;
  
--- 749,755 ----
  	return 0;
  
      QFont::Script script;
!     SCRIPT_FOR_CHAR( script, ch, d );
  
      int width;
  
diff -rc qt-x11-free-3.3.3/src/kernel/qfontdata_p.h qt-x11-free-3.3.3/src/kernel/qfontdata_p.h
*** qt-x11-free-3.3.3/src/kernel/qfontdata_p.h	Thu Aug  5 23:42:06 2004
--- qt-x11-free-3.3.3/src/kernel/qfontdata_p.h	Tue Dec 21 02:20:54 2004
***************
*** 150,155 ****
--- 150,160 ----
  #if defined(Q_WS_X11) || defined(Q_WS_WIN)
  	if ( ! engineData || ! engineData->engines[script] )
  	    ((QFontPrivate *) this)->load( script );
+ #ifdef Q_WS_X11
+ 	if ( script == QFont::Unicode &&
+ 	     engineData->engines[script] == (QFontEngine *)-1 )
+ 	    return engineForScript( QFontPrivate::globalScript ); // NoScript or Han
+ #endif // Q_WS_X11
  	return engineData->engines[script];
  #else
          if ( ! engineData || ! engineData->engine )
***************
*** 158,163 ****
--- 163,173 ----
  #endif // Q_WS_X11 || Q_WS_WIN
      }
  
+ #ifdef Q_WS_X11
+     static QFont::Script globalScript;
+     QFont::Script checkGlobalScript( QFont::Script script, const QChar &ch );
+ #endif // Q_WS_X11
+ 
      QFontDef request;
      QFontEngineData *engineData;
      QPaintDevice *paintdevice;
diff -rc qt-x11-free-3.3.3/src/kernel/qfontdatabase_x11.cpp qt-x11-free-3.3.3/src/kernel/qfontdatabase_x11.cpp
*** qt-x11-free-3.3.3/src/kernel/qfontdatabase_x11.cpp	Tue Dec 21 00:52:21 2004
--- qt-x11-free-3.3.3/src/kernel/qfontdatabase_x11.cpp	Tue Dec 21 20:42:35 2004
***************
*** 1132,1137 ****
--- 1132,1138 ----
  	    family->scripts[QFont::UnknownScript] = QtFontFamily::Supported;
  	}
  #endif // QT_XFT2
+ 	family->scripts[QFont::Unicode] = QtFontFamily::Supported;
  
  	QCString file = (file_value ? file_value : "");
  	family->fontFilename = file;
***************
*** 1559,1564 ****
--- 1560,1605 ----
  	    }
  	}
  #endif // XFT_MATRIX
+ 
+ #ifdef QT_XFT2
+ 	int bold_values[3] = { QFont::DemiBold, QFont::Black, QFont::Bold };
+ 
+ 	for ( int j = 0; j < db->families[i]->count; ++j ) {	// each foundry
+ 	    QtFontFoundry *foundry = db->families[i]->foundries[j];
+ 	    for ( int k = 0; k < foundry->count; ++k ) {
+ 		QtFontStyle *style = foundry->styles[k];
+ 		if ( style->key.weight > QFont::Normal ) continue;
+ 
+ 		QtFontSize *size = style->pixelSize( SMOOTH_SCALABLE );
+ 		if ( ! size ) continue; // should not happen
+ 		QtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE );
+ 		if ( ! enc ) continue; // should not happen either
+ 
+ 		QtFontStyle::Key key = style->key;
+ 
+ 		// does this style have any bold equivalents?
+ 		QtFontStyle *equiv = 0;
+ 		for ( int m = 0; m < 3; ++m ) {
+ 		    key.weight = bold_values[m];
+ 		    equiv = foundry->style( key );
+ 		    if ( equiv ) break;
+ 		}
+ 
+ 		if ( equiv ) continue;
+ 
+ 		// let's fake bold one...
+ 		equiv = foundry->style( key, TRUE );
+ 		equiv->smoothScalable = TRUE;
+ 		equiv->rawName = style->rawName;
+ 
+ 		QtFontSize *equiv_size = equiv->pixelSize( SMOOTH_SCALABLE, TRUE );
+ 		QtFontEncoding *equiv_enc = equiv_size->encodingID( -1, 0, 0, 0, 0, TRUE );
+ 
+ 		// keep the same pitch
+ 		equiv_enc->pitch = enc->pitch;
+ 	    }
+ 	}
+ #endif // !QT_XFT2
      }
  #endif
  
diff -rc qt-x11-free-3.3.3/src/kernel/qpsprinter.cpp qt-x11-free-3.3.3/src/kernel/qpsprinter.cpp
*** qt-x11-free-3.3.3/src/kernel/qpsprinter.cpp	Thu Aug  5 23:42:05 2004
--- qt-x11-free-3.3.3/src/kernel/qpsprinter.cpp	Tue Dec 21 20:45:48 2004
***************
*** 98,103 ****
--- 98,109 ----
  #include "qtextlayout_p.h"
  #include "qtextengine_p.h"
  extern bool qt_has_xft;
+ 
+ #ifndef QT_NO_XFTFREETYPE
+ #include <ft2build.h>
+ #include FT_OUTLINE_H
+ #endif
+ 
  #endif
  
  static bool qt_gen_epsf = FALSE;
***************
*** 2074,2079 ****
--- 2080,2111 ----
  
  // ================== TTF ====================
  
+ #ifndef QT_NO_XFTFREETYPE
+ 
+ static void
+ getXftData( const QFontEngine *engine,
+ 	    int &index, int &weight, int &slant, XftMatrix &matrix )
+ {
+     XftPattern*  font = static_cast<const QFontEngineXft *>( engine )->pattern();
+     XftMatrix    unit = { 1.0, 0, 0, 1.0 };
+     XftMatrix*   mat;
+ 
+     index  = 0;
+     weight = XFT_WEIGHT_MEDIUM;
+     slant  = XFT_SLANT_ROMAN;
+     matrix = unit;
+ 
+     XftPatternGetInteger( font, XFT_INDEX, 0, &index );
+     XftPatternGetInteger( font, XFT_WEIGHT, 0, &weight );
+     XftPatternGetInteger( font, XFT_SLANT, 0, &slant );
+ 
+     if ( XftPatternGetMatrix( font, XFT_MATRIX, 0, &mat ) == XftResultMatch )
+ 	matrix = *mat;
+ }
+ 
+ #endif // QT_NO_XFTFREETYPE
+ 
+ 
  typedef Q_UINT8  BYTE;
  typedef Q_UINT16 USHORT;
  typedef Q_UINT16 uFWord;
***************
*** 2182,2187 ****
--- 2214,2229 ----
  
      int indexToLocFormat;         /* short or long offsets */
  
+ #ifndef QT_NO_XFTFREETYPE
+     FT_Face face;
+     int index;
+     int weight;
+     int slant;
+     XftMatrix matrix;
+ 
+     QString StyleName_Extension;
+ #endif // QT_NO_XFTFREETYPE
+ 
  };
  
  
***************
*** 2291,2296 ****
--- 2333,2390 ----
  #endif
    offset_table = (unsigned char*) data.data(); /* first 12 bytes */
  
+ #ifndef QT_NO_XFTFREETYPE
+   if ( target_type == 42 ) {
+     if ( !( d[0] == '0' && d[1] == '1' && d[2] == '0' && d[3] == '0' ) ) {
+       defective = TRUE;
+       return;
+     }
+   }
+ 
+   face = 0;
+   StyleName_Extension = "";
+   getXftData( f, index, weight, slant, matrix );
+ 
+   if ( qt_has_xft && f->type() == QFontEngine::Xft ) {
+     extern FT_Library  _XftFTlibrary;
+ 
+     if ( FT_New_Memory_Face( _XftFTlibrary,
+                              (const FT_Byte*)data.data(),
+                              data.size(), index, &face ) ||
+          ( face->face_flags & FT_FACE_FLAG_SCALABLE ) == 0 ) {
+       defective = TRUE;
+       return;
+     }
+ 
+     FT_Set_Pixel_Sizes( face, 1000, 1000 );
+ 
+     bool bold   = ( face->style_flags & FT_STYLE_FLAG_BOLD   ) != 0;
+     bool italic = ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0;
+ 
+     if ( weight > XFT_WEIGHT_MEDIUM && !bold )
+       StyleName_Extension += "Bold";
+     if ( slant > XFT_SLANT_ROMAN && !italic )
+       StyleName_Extension += "Oblique";
+ 
+     if ( !StyleName_Extension.isEmpty() )
+       StyleName_Extension = "-" + StyleName_Extension;
+ 
+     if ( matrix.xx != 1.0 || matrix.xy != 0.0 ||
+          matrix.yx != 0.0 || matrix.yy != 1.0 )
+       StyleName_Extension += QString( "-%1-%2-%3-%4" )
+                                      .arg( matrix.xx, 0, 'f' )
+                                      .arg( matrix.yx, 0, 'f' )
+                                      .arg( matrix.xy, 0, 'f' )
+                                      .arg( matrix.yy, 0, 'f' );
+ 
+     StyleName_Extension.replace( '.', '_' );
+   }
+ 
+   if ( d[0] == 't' && d[1] == 't' && d[2] == 'c' && d[3] == 'f' )
+     offset_table += getULONG( offset_table + 12 + 4 * index );
+ #endif
+ 
+ 
    /* Determine how many directory entries there are. */
    numTables = getUSHORT( offset_table + 4 );
  
***************
*** 2406,2411 ****
--- 2500,2510 ----
  //  qDebug("number of glyphs is %d", numGlyphs);
    replacementList = makePSFontNameList( f, psname );
    uni2glyphSetup();
+ 
+ #ifndef QT_NO_XFTFREETYPE
+   psname   += StyleName_Extension;
+   FullName += StyleName_Extension;
+ #endif
  }
  
  
***************
*** 2540,2546 ****
      if( target_type == 42 )
          s << "%%Creator: Converted from TrueType to type 42 by Qt\n";
      else
!         s << "%%Creator: Converted from TrueType by Qt\n";
  
      /* If VM usage information is available, print it. */
      if( target_type == 42 && post_table)
--- 2639,2645 ----
      if( target_type == 42 )
          s << "%%Creator: Converted from TrueType to type 42 by Qt\n";
      else
!         s << "%%Creator: Converted from TrueType/OpenType by Qt\n";
  
      /* If VM usage information is available, print it. */
      if( target_type == 42 && post_table)
***************
*** 2562,2568 ****
          s << "/_d{bind def}bind def\n";
          s << "/_m{moveto}_d\n";
          s << "/_l{lineto}_d\n";
!         s << "/_cl{closepath eofill}_d\n";
          s << "/_c{curveto}_d\n";
          s << "/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d\n";
          s << "/_e{exec}_d\n";
--- 2661,2667 ----
          s << "/_d{bind def}bind def\n";
          s << "/_m{moveto}_d\n";
          s << "/_l{lineto}_d\n";
!         s << "/_cl{closepath fill}_d\n";
          s << "/_c{curveto}_d\n";
          s << "/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d\n";
          s << "/_e{exec}_d\n";
***************
*** 2576,2582 ****
--- 2675,2689 ----
      if(target_type == 42)
          s << "/FontMatrix[1 0 0 1 0 0]def\n";
      else
+ #ifndef QT_NO_XFTFREETYPE
+         s << QString( "/FontMatrix[%1 %2 %3 %4 0 0]def\n" )
+                      .arg( 0.001 * matrix.xx, 0, 'f', 6 )
+                      .arg( 0.001 * matrix.yx, 0, 'f', 6 )
+                      .arg( 0.001 * matrix.xy, 0, 'f', 6 )
+                      .arg( 0.001 * matrix.yy, 0, 'f', 6 );
+ #else
          s << "/FontMatrix[.001 0 0 .001 0 0]def\n";
+ #endif
  
      s << "/FontBBox[";
      s<< llx;
***************
*** 2719,2724 ****
--- 2826,2836 ----
  
      s << "end readonly def\n";
  
+     if ( face ) {
+       FT_Done_Face( face );
+       face = 0;
+     }
+ 
      // === trailer ===
  
      /* If we are generating a type 3 font, we need to provide */
***************
*** 2861,2867 ****
              offset = getULONG( ptr + 8 );
              //length = getULONG( ptr + 12 );
  
!             table = offset_table + offset;
              return table;
          }
  
--- 2973,2979 ----
              offset = getULONG( ptr + 8 );
              //length = getULONG( ptr + 12 );
  
!             table = (BYTE*)data.data() + offset;
              return table;
          }
  
***************
*** 3364,3369 ****
--- 3476,3598 ----
    }
  }
  
+ 
+ #ifndef QT_NO_XFTFREETYPE
+ 
+ #undef DOWNSCALE
+ #define DOWNSCALE( x ) ( ( (x) + 32 ) >> 6 )
+ 
+ extern "C" {
+ 
+ static FT_Vector  from;
+ 
+   static FT_Error
+   PSMovetoFT( FT_Vector*  to, QTextStream *s )
+   {
+     if ( !to ) {
+       stack( 100, 1, *s );
+       (*s) << " _cl";
+     } else {
+       stack( 100, 3, *s );
+       (*s) << DOWNSCALE( to->x ) << " "
+            << DOWNSCALE( to->y ) << " _m\n";
+       from = *to;
+     }
+ 
+     return FT_Err_Ok;
+   }
+ 
+   static FT_Error
+   PSLinetoFT( FT_Vector*  to,
+               QTextStream *s )
+   {
+     stack( 100, 3, *s );
+     (*s) << DOWNSCALE( to->x ) << " "
+          << DOWNSCALE( to->y ) << " _l\n";
+     from = *to;
+     return FT_Err_Ok;
+   }
+ 
+   static FT_Error
+   PSCubictoFT( FT_Vector*  ctrl1, FT_Vector*  ctrl2, FT_Vector*  to,
+                QTextStream *s )
+   {
+     stack( 100, 7, *s );
+     (*s) << DOWNSCALE( ctrl1->x ) << " "
+          << DOWNSCALE( ctrl1->y ) << " "
+          << DOWNSCALE( ctrl2->x ) << " "
+          << DOWNSCALE( ctrl2->y ) << " "
+          << DOWNSCALE( to->x    ) << " "
+          << DOWNSCALE( to->y    ) << " _c\n";
+     from = *to;
+     return FT_Err_Ok;
+   }
+ 
+   static FT_Error
+   PSConictoFT( FT_Vector*  ctrl, FT_Vector*  to,
+                QTextStream *s )
+   {
+     FT_Vector  ctrl1, ctrl2;
+ 
+ 
+     ctrl1.x = ( from.x + 2*ctrl->x ) / 3;
+     ctrl1.y = ( from.y + 2*ctrl->y ) / 3;
+     ctrl2.x = ( to->x  + 2*ctrl->x ) / 3;
+     ctrl2.y = ( to->y  + 2*ctrl->y ) / 3;
+ 
+     return PSCubictoFT( &ctrl1, &ctrl2, to, s );
+   }
+ 
+ } // extern "C"
+ 
+ static void
+ charprocFT( FT_Face  face, FT_UInt  glyph_index,
+             int weight, int slant, QTextStream &s )
+ {
+   static const FT_Outline_Funcs  funcs =
+   {
+     (FT_Outline_MoveToFunc)  PSMovetoFT,
+     (FT_Outline_LineToFunc)  PSLinetoFT,
+     (FT_Outline_ConicToFunc) PSConictoFT,
+     (FT_Outline_CubicToFunc) PSCubictoFT,
+     0, 0
+   };
+ 
+   FT_Int32  load_flags = FT_LOAD_NO_BITMAP |
+                          FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
+ 
+   Q_UNUSED( weight );
+   Q_UNUSED( slant );
+ 
+   if ( !FT_Load_Glyph( face, glyph_index, load_flags ) ) {
+     FT_Glyph_Metrics*  metrics = &face->glyph->metrics;
+ 
+     stack( 100, 7, s );
+     s << ( ( face->glyph->linearHoriAdvance + 0x8000L ) >> 16 );
+     s << " 0 ";
+     s << DOWNSCALE( metrics->horiBearingX );
+     s << " ";
+     s << DOWNSCALE( metrics->horiBearingY - metrics->height );
+     s << " ";
+     s << DOWNSCALE( metrics->horiBearingX + metrics->width );
+     s << " ";
+     s << DOWNSCALE( metrics->horiBearingY );
+     s << " _sc\n";
+ 
+     FT_Outline_Decompose( &face->glyph->outline, &funcs, &s );
+     PSMovetoFT( 0, &s );
+ 
+   } else {
+     stack( 7, 7, s );
+     s << "0 0 0 0 0 0 0 _sc\n";
+   }
+ 
+   stack_end( s );
+   return;
+ }
+ 
+ #endif // QT_NO_XFTFREETYPE
+ 
  // postscript drawing commands
  
  static void PSMoveto(FWord x, FWord y, QTextStream& ts)
***************
*** 3758,3763 ****
--- 3987,3998 ----
    charproc_data cd;
  
    glyphset[charindex] = TRUE;
+ 
+ #ifndef QT_NO_XFTFREETYPE
+   if ( face )
+     return;
+ #endif // QT_NO_XFTFREETYPE
+ 
    //printf("subsetting %s ==> ",glyphName(charindex).latin1());
  
    /* Get a pointer to the data. */
***************
*** 3959,3964 ****
--- 4194,4204 ----
    s << "\n";
  #endif
  
+   if ( face ) {
+     charprocFT( face, charindex, weight, slant, s );
+     return;
+   }
+ 
    /* Get a pointer to the data. */
    BYTE* glyph = charprocFindGlyphData( charindex );
  
***************
*** 4905,4913 ****
  	    char *filename = 0;
  	    XftPatternGetString (pattern, XFT_FILE, 0, &filename);
  	    //qDebug("filename for font is '%s'", filename);
  	    if ( filename ) {
  		fontfilename = QString::fromLocal8Bit( filename );
! 		xfontname = fontfilename;
  	    }
  	} else
  #endif
--- 5145,5163 ----
  	    char *filename = 0;
  	    XftPatternGetString (pattern, XFT_FILE, 0, &filename);
  	    //qDebug("filename for font is '%s'", filename);
+ 
+ 	    int index, weight, slant;
+ 	    XftMatrix  matrix;
+ 	    getXftData (engine, index, weight, slant, matrix);
+ 
+ 	    QString  style = QString("-I%1-W%2-S%3-M[%4,%5,%6,%7]")
+ 				.arg(index).arg(weight).arg(slant)
+ 				.arg(matrix.xx).arg(matrix.xy)
+ 				.arg(matrix.yx).arg(matrix.yy);
+ 
  	    if ( filename ) {
  		fontfilename = QString::fromLocal8Bit( filename );
! 		xfontname = fontfilename + style;
  	    }
  	} else
  #endif
***************
*** 5046,5051 ****
--- 5296,5307 ----
              type = PFA;
          else if (d[0]==0x00 && d[1]==0x01 && d[2]==0x00 && d[3]==0x00)
              type = TTF;
+ #ifndef QT_NO_XFTFREETYPE
+         else if (d[0]=='t' && d[1]=='t' && d[2]=='c' && d[3]=='f')
+             type = TTF;
+         else if (d[0]=='O' && d[1]=='T' && d[2]=='T' && d[3]=='O')
+             type = TTF;
+ #endif // QT_NO_XFTFREETYPE
          else
              type = NONE;
      } else
diff -rc qt-x11-free-3.3.3/src/kernel/qtextengine.cpp qt-x11-free-3.3.3/src/kernel/qtextengine.cpp
*** qt-x11-free-3.3.3/src/kernel/qtextengine.cpp	Thu Aug  5 23:42:08 2004
--- qt-x11-free-3.3.3/src/kernel/qtextengine.cpp	Tue Dec 21 02:30:46 2004
***************
*** 187,194 ****
      if ( control.singleLine ) {
  	for ( int i = start; i <= stop; i++ ) {
  
! 	    unsigned short uc = text[i].unicode();
! 	    QFont::Script s = (QFont::Script)scriptForChar( uc );
  	    if (s == QFont::UnknownScript || s == QFont::CombiningMarks)
  		s = script;
  
--- 187,193 ----
      if ( control.singleLine ) {
  	for ( int i = start; i <= stop; i++ ) {
  
! 	    QFont::Script s = (QFont::Script)scriptForChar( text[i], engine->fnt );
  	    if (s == QFont::UnknownScript || s == QFont::CombiningMarks)
  		s = script;
  
***************
*** 204,210 ****
  	for ( int i = start; i <= stop; i++ ) {
  
  	    unsigned short uc = text[i].unicode();
! 	    QFont::Script s = (QFont::Script)scriptForChar( uc );
  	    if (s == QFont::UnknownScript || s == QFont::CombiningMarks)
  		s = script;
  
--- 203,209 ----
  	for ( int i = start; i <= stop; i++ ) {
  
  	    unsigned short uc = text[i].unicode();
! 	    QFont::Script s = (QFont::Script)scriptForChar( text[i], engine->fnt );
  	    if (s == QFont::UnknownScript || s == QFont::CombiningMarks)
  		s = script;
  
diff -rc qt-x11-free-3.3.3/src/tools/qunicodetables_p.h qt-x11-free-3.3.3/src/tools/qunicodetables_p.h
*** qt-x11-free-3.3.3/src/tools/qunicodetables_p.h	Thu Aug  5 23:41:57 2004
--- qt-x11-free-3.3.3/src/tools/qunicodetables_p.h	Tue Dec 21 02:22:07 2004
***************
*** 50,55 ****
--- 50,56 ----
  
  #ifndef QT_H
  #include "qstring.h"
+ #include "private/qfontdata_p.h"
  #endif // QT_H
  
  #ifdef QT_NO_UNICODETABLES
***************
*** 227,234 ****
  #endif
  }
  
! inline int scriptForChar( ushort uc )
  {
      unsigned char script = QUnicodeTables::scriptTable[(uc>>8)];
      if ( script >= QUnicodeTables::SCRIPTS_INDIC ) {
  	if ( script == QUnicodeTables::SCRIPTS_INDIC ) {
--- 228,236 ----
  #endif
  }
  
! inline int scriptForChar( const QChar &ch, QFontPrivate *fnt = 0 )
  {
+     unsigned short uc = ch.unicode();
      unsigned char script = QUnicodeTables::scriptTable[(uc>>8)];
      if ( script >= QUnicodeTables::SCRIPTS_INDIC ) {
  	if ( script == QUnicodeTables::SCRIPTS_INDIC ) {
***************
*** 242,263 ****
  	    script = QUnicodeTables::otherScripts[index];
  	}
      }
-     return script;
- }
  
  #ifdef Q_WS_X11
! #define SCRIPT_FOR_CHAR( script, c ) 	\
! do { 						\
!     unsigned short _uc = (c).unicode(); 		\
!     if ( _uc < 0x100 ) {				\
! 	script = QFont::Latin;		\
!     } else { 					\
!         script = (QFont::Script)scriptForChar( _uc ); 	\
!     } 						\
! } while( FALSE )
  #else
! #define SCRIPT_FOR_CHAR( script, c ) \
!     script = (QFont::Script)scriptForChar( (c).unicode() )
! #endif
  
  #endif
--- 244,261 ----
  	    script = QUnicodeTables::otherScripts[index];
  	}
      }
  
  #ifdef Q_WS_X11
!     if ( fnt )
!       script = fnt->checkGlobalScript( (QFont::Script)script, ch );
  #else
!     Q_UNUSED( fnt );
! #endif // Q_WS_X11
! 
!     return script;
! }
! 
! #define SCRIPT_FOR_CHAR( script, c, fnt ) \
!     script = (QFont::Script)scriptForChar( c, fnt )
  
  #endif
