[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: □□涟□逃de2.0-20001016debian□□koffice□臭诳□晔?凇踟唷酢酢?Message-Id: <20001020225930.A685@yahoo.com>



On Sun, Oct 22, 2000 at 03:21:36AM +0800, Yu Guanghui wrote:

> stable. how about you? Could you use TrueType in KDE2?

Certainly. You probably should not set font. What we really ought to do is to
set fontset. However kde2 does not provide a way to do that. That's because
the qt library, which kde2 based upon , does not have any api that allows
explicitly specifying fontset. As a work around, something called font guessing
was introduced into qt. You create an /etc/fontguess or $HOME/.fontguess file
to tell qt what font to use with each one of the standard font family (thus
create a font set). Below is what my .fontguess looks like:

[gb2312.1980-0]
helvetic simsun
courier  kai
times    simsun
lucida   simsun

The second column is family name for gb2312 font, and you could replace them
with your favorites. However current qt does NOT support name with spaces, such
as "ar sungitl gb". I attached a patch which was from Ming-Che Chuang (I
modified it a little bit). Apply it and recompile qt, then you can use
"ar sungitl gb" font.

Regards,
rigel


qt-2.2.1 patch:
--------------------------cut-------------------------------------
diff -Naur qt-2.2.1.orig/src/kernel/qfont_x11.cpp qt-2.2.1/src/kernel/qfont_x11.cpp
--- qt-2.2.1.orig/src/kernel/qfont_x11.cpp	Wed Oct  4 02:48:48 2000
+++ qt-2.2.1/src/kernel/qfont_x11.cpp	Mon Oct 23 01:02:35 2000
@@ -1705,6 +1705,41 @@
 }
 
 // Font Guessing
+static
+QStringList splitFamilies(const QString &s)
+{
+    QStringList sl;
+    QString buf;
+    int i=0,j=0;
+    while (1) {
+	while ( i < s.length() && s[i].isSpace() ) i++;
+	if ( s[i] == '"' ) {
+	    j = s.find('"', i+1);
+	    if ( j == -1 ) {
+		buf = s.right( s.length() - i - 1 );
+		sl.append( buf );
+		return sl;
+	    }
+	    buf = s.mid( i+1, j-i-1 );
+	}
+	else {
+	    j = i;
+	    while ( j < s.length() && !s[j].isSpace() ) j++;
+	    buf = s.mid( i, j-i );
+	}
+
+   	if ( !buf.isEmpty() ) {
+	    sl.append(buf);
+	    buf="";
+	}
+	else
+	    return sl;
+
+	i = j + 1;
+    }
+}
+
+// Font Guessing
 bool QFont_Private::fontmapping(const QString& filename)
 {
     QStringList chsetlst;
@@ -1722,8 +1757,9 @@
 		chsetlst = QStringList::split( sep, s );
 	    } else {
 		QStringList familylst;
-		QRegExp sep( "[ =\t]" );
-		familylst = QStringList::split( sep, s );
+		//QRegExp sep( "[ =\t]" );
+		//familylst = QStringList::split( sep, s );
+		familylst = splitFamilies(s);
 		if ( !chsetlst.isEmpty() && !familylst.isEmpty() ) {
 		    if ( !fontGuessingList )
 			fontGuessingList = new QList<FontGuessingPair>;
--------------------------cut-------------------------------------



Reply to: