Kingo 发表于 2004-1-1 17:08:51

有一个解决一些特殊符号显示问题的qt补丁

这个补丁由acura(可能就是论坛上的lucida吧:))提供,这个补丁是个混合补丁,其中一部分是hooey写的,一部分是firefly的粗体补丁。

diff -ruN qt.orig/src/kernel/qapplication_x11.cpp qt/src/kernel/qapplication_x11.cpp
--- qt.orig/src/kernel/qapplication_x11.cpp        2003-10-17 20:26:49.000000000 -0700
+++ qt/src/kernel/qapplication_x11.cpp        2003-10-17 20:30:00.000000000 -0700
@@ -999,7 +999,9 @@
        QString fam, skey;
        QStringList::Iterator it = fontsubs.begin();
        while (it != fontsubs.end()) {
-          fam = (*it++).latin1();
+          // Modify by Firefly ([email protected])
+          // 替代字型不要转成 latin1
+          fam = *it++;
          skey = "/qt/Font Substitutions/" + fam;
          subs = settings.readListEntry(skey);
          QFont::insertSubstitutions(fam, subs);
diff -ruN qt.orig/src/kernel/qfontdatabase_x11.cpp qt/src/kernel/qfontdatabase_x11.cpp
--- qt.orig/src/kernel/qfontdatabase_x11.cpp        2003-10-17 20:26:50.000000000 -0700
+++ qt/src/kernel/qfontdatabase_x11.cpp        2003-10-17 20:36:43.000000000 -0700
@@ -665,6 +665,11 @@

static void loadXlfds( const char *reqFamily, int encoding_id )
{
+    // Add by Firefly ([email protected])
+    // 如果 QT 使用 XFT2 则不用解析 XLFD 了
+    if (qt_has_xft)
+        return;
+
   QtFontFamily *fontFamily = reqFamily ? db->family( reqFamily ) : 0;

   // make sure we don't load twice
@@ -788,6 +793,14 @@
   if (!qt_has_xft)
        return;

+// Add by Firefly ([email protected])
+// 取得 fontconfig 版本
+#ifdef QT_XFT2
+    int fontconfigVersion = FcGetVersion();
+#else
+    int fontconfigVersion = 0;
+#endif // QT_XFT2
+
   XftFontSet*fonts;

   QString familyName;
@@ -805,6 +818,9 @@
                     (const char *)0,
                     XFT_FAMILY, XFT_WEIGHT, XFT_SLANT,
                     XFT_SPACING, XFT_FILE, XFT_INDEX,
+                     // Add by Firefly([email protected])
+                     // 制造商名称
+                     XFT_FOUNDRY,
#ifdef QT_XFT2
                     FC_CHARSET,
#endif // QT_XFT2
@@ -818,7 +834,14 @@
        rawName = familyName = QString::fromUtf8(value);
        familyName.replace('-', ' ');
        familyName.replace("/", "");
-
+         // Add by Firefly ([email protected])
+         // Fontconfig 2.1.94 以后,才会记录制造商名称
+         QString foundryName = QString::null;
+         if (fontconfigVersion >= 20194 &&
+                XftPatternGetString (fonts->fonts[i],
+                         XFT_FOUNDRY, 0, &value) == XftResultMatch)
+           foundryName = QString::fromUtf8(value);
+        
        slant_value = XFT_SLANT_ROMAN;
        weight_value = XFT_WEIGHT_MEDIUM;
        spacing_value = XFT_PROPORTIONAL;
@@ -861,7 +884,7 @@
        styleKey.oblique = (slant_value == XFT_SLANT_OBLIQUE);
        styleKey.weight = getXftWeight( weight_value );

-        QtFontFoundry *foundry = family->foundry( QString::null,TRUE );
+        QtFontFoundry *foundry = family->foundry( foundryName,TRUE );
        QtFontStyle *style = foundry->style( styleKey,TRUE );

        style->smoothScalable = TRUE;
@@ -871,6 +894,25 @@
        QtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE );
        enc->pitch = ( spacing_value >= XFT_CHARCELL ? 'c' :
                     ( spacing_value >= XFT_MONO ? 'm' : 'p' ) );
+
+        // Add by Firefly ([email protected])
+        // 如果这个字体不是粗体,找找看是否已经有了粗体设定?
+#if 1
+        if (weight_value <= XFT_WEIGHT_MEDIUM) {
+          QtFontStyle *fakeStyle;
+          styleKey.weight = getXftWeight(XFT_WEIGHT_BOLD);
+          fakeStyle = foundry->style(styleKey);
+          // 找不到! 表示该字样式没有粗体,那么就伪造一个
+          if ( !fakeStyle ) {
+                fakeStyle = foundry->style(styleKey, TRUE);
+                fakeStyle->smoothScalable = TRUE;
+                QtFontSize *fake_size = fakeStyle->pixelSize(SMOOTH_SCALABLE, TRUE);
+                QtFontEncoding *fake_enc = fake_size->encodingID(-1,0,0,0,0,TRUE);
+                fake_enc->pitch = enc->pitch;
+          }
+        }
+#endif
+
   }

   XftFontSetDestroy (fonts);
diff -ruN qt.orig/src/tools/qunicodetables.cpp qt/src/tools/qunicodetables.cpp
--- qt.orig/src/tools/qunicodetables.cpp        2003-06-24 00:06:51.000000000 -0700
+++ qt/src/tools/qunicodetables.cpp        2003-10-17 20:37:14.000000000 -0700
@@ -13090,7 +13090,7 @@
#define SCRIPTS_18 48
   0xaf, Mongolian, 0xff, Unicode,                             // row 0x18, index 46
#define SCRIPTS_20 52
-    0x0b, Unicode, 0x0d, UnknownScript, 0x6f, Unicode, 0x9f, NumberForms,
+    0x0b, Unicode, 0x0d, Han, 0x6f, Han, 0x9f, NumberForms,
   0xab, CurrencySymbols, 0xac, Latin,
   0xcf, CurrencySymbols, 0xff, CombiningMarks,                // row 0x20, index 50
#define SCRIPTS_21 68
@@ -13109,11 +13109,11 @@
   0x06, Latin, 0x1c, Unicode, 0x4f, Hebrew,
   0xff, Arabic,                                                // row 0xfb, index 90
#define SCRIPTS_fe 104
-    0x1f, Unicode, 0x2f, CombiningMarks, 0x6f, Unicode,
+    0x1f, Unicode, 0x2f, CombiningMarks, 0x6f, Han,
   0xff, Arabic,                                                // row 0xfe, index 98
#define SCRIPTS_ff 112
   0x5e, Katakana, 0x60, Unicode,                      // row 0xff, index 106
-    0x9f, KatakanaHalfWidth, 0xff, Unicode
+    0xef, KatakanaHalfWidth, 0xff, Unicode
};

// (uc-0x0900)>>7
diff -ruN qt.orig/src/kernel/qfontdatabase.cpp qt/src/kernel/qfontdatabase.cpp
--- qt.orig/src/kernel/qfontdatabase.cpp    2003-10-17 20:26:50.000000000 -0700
+++ qt/src/kernel/qfontdatabase.cpp 2003-10-17 20:37:14.000000000 -0700
@@ -454,7 +454,7 @@
   // Ogham,
   0x1680,
   // SpacingModifiers,
-    0x02b0,
+    0x02c7,
   // CombiningMarks,
   0x0300,

@@ -526,19 +526,19 @@

   // Symbols
   // CurrencySymbols,
-    0x20aa,
+    0x20ac,
   // LetterlikeSymbols,
-    0x2122,
+    0x2103,
   // NumberForms,
-    0x215b,
+    0x2160,
   // MathematicalOperators,
-    0x222b,
+    0x2199,
   // TechnicalSymbols,
-    0x2440,
+    0x2312,
   // GeometricSymbols,
   0x2500,
   // MiscellaneousSymbols,
-    0x2600,
+    0x2640,
   // EnclosedAndSquare,
   0x2460,
   // Braille,
@@ -558,7 +558,7 @@
   0x1770,

   // KatakanaHalfWidth
-    0xff65,
+    0xffe4,

   // NScripts
   0x0000,

Kingo 发表于 2004-1-1 17:10:42

哦,忘记说明了,适用于qt-3.2.3;至于其他版本能不能用我就不清楚了。呵呵!

lucida 发表于 2004-1-2 00:13:26

a...你问问hooey吧
我记得他以前说不太好意思post出来 :)

maxofmin 发表于 2004-1-2 13:16:01

对qt程序的性能有没有什么影响,听说akito的qt补丁有些导致kde运行缓慢.

Kingo 发表于 2004-1-2 14:43:36

经过我的测试,会变慢只是qfontdatabase那个补丁。或许只是我的机子上有问题,到现在为止,只有报告了这个问题。

To lucida: 能用就行了,反正这个东东只是解决一些小问题,没有大影响。不过,如果hooey确实觉得不能发的话,我会把它删了。 :oops:
页: [1]
查看完整版本: 有一个解决一些特殊符号显示问题的qt补丁