Bug 448012 - [Fix_is_Ready:11.1] Qt4 uses Nimbus Sans L as "Sans Serif" font
Summary: [Fix_is_Ready:11.1] Qt4 uses Nimbus Sans L as "Sans Serif" font
Status: RESOLVED FIXED
: 461181 (view as bug list)
Alias: None
Product: openSUSE 11.1
Classification: openSUSE
Component: KDE4 Applications (show other bugs)
Version: Beta 5
Hardware: Other Other
: P5 - None : Normal with 10 votes (vote)
Target Milestone: ---
Assignee: Dirk Mueller
QA Contact: E-mail List
URL:
Whiteboard:
Keywords: Fix_is_Ready
Depends on:
Blocks:
 
Reported: 2008-11-23 22:19 UTC by Arseniy Lartsev
Modified: 2009-01-06 19:59 UTC (History)
3 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseniy Lartsev 2008-11-23 22:19:41 UTC
In any Qt4 (and consequently KDE4) applications font "Sans Serif" looks exactly like Nimbus Sans L. But according to output of "fc-match sans", it should be Liberation Sans or DejaVu Sans depending on whether the latter is installed.
Comment 1 Will Stephenson 2008-11-24 13:10:39 UTC
Reproduced, qtconfig says the default font is "Sans".

Dirk, can you give any input on what Qt4 is doing here?  Is "fc-match sans" the right thing to compare Qt's behaviour to?
Comment 2 Mike Fabian 2008-11-25 14:46:41 UTC
Yes, "Sans" or "Sans Serif" is Qt should be the same as

"sans-serif" in fontconfig ("sans-serif" =  "sans serif" = "sans" in
fontconfig, there is no difference in these 3 spellings) 

I.e. when qtconfig says the default font is "Sans" it should
indeed used the font returned by "fc-match sans-serif".
Comment 3 Arseniy Lartsev 2008-12-22 10:21:05 UTC
This is due to hardcoded font substitution in Qt 4.4.3: "Sans Serif" is substituted by "helvetica" which in turn equals Nimbus Sans L according to what "fc-match helvetica" says.

This substitution is defined at src/gui/text/qfont.cpp on line 1768. After commenting out this line, Qt's "Sans Serif" on my system becomes equal Liberation Sans.

Corresponding patch for Qt 4.4.3:

diff -rup src/gui/text/qfont.cpp src/gui/text/qfont.cpp
--- qt-x11-opensource-src-4.4.3-orig/src/gui/text/qfont.cpp	2008-09-27 12:58:47.000000000 +0400
+++ qt-x11-opensource-src-4.4.3/src/gui/text/qfont.cpp	2008-12-21 02:04:55.000000000 +0300
@@ -1765,7 +1765,7 @@ static void initFontSubst()
         "arial",        "helvetica",
         "times new roman", "times",
         "courier new",  "courier",
-        "sans serif",   "helvetica",
+//        "sans serif",   "helvetica",  -- Better let fontconfig do it's work
 #elif defined(Q_WS_WIN)
         "times",        "times new roman",
         "courier",      "courier new",
Comment 4 Arseniy Lartsev 2008-12-22 22:45:38 UTC
Another option is changing /etc/fonts/conf.d/30-metric-aliases.conf
Comment 5 Forgotten User --EoyBps8f 2008-12-27 08:39:49 UTC
*** Bug 461181 has been marked as a duplicate of this bug. ***
Comment 6 Will Stephenson 2009-01-05 11:22:41 UTC
Apparently this is the correct fix (see "Where are font mappings for generic fonts defined in KDE" thread on kde-devel@kde.org)

diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 7e7e9bc..d878d5b 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
 -35,6 +35,7 @@
 
 #ifdef Q_WS_X11
 #include "qx11info_x11.h"
+#include <private/qt_x11_p.h>
 #endif
 #ifdef Q_WS_QWS
 #include "qscreen_qws.h"
 -1756,6 +1757,10 @@ static void initFontSubst()
     Q_ASSERT(fontSubst != 0);
     if (!fontSubst->isEmpty())
         return;
+#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
+    if (X11->has_fontconfig)
+        return;
+#endif
 
     for (int i=0; initTbl[i] != 0; i += 2) {
         QStringList &list = (*fontSubst)[QString::fromLa
Comment 7 Dirk Mueller 2009-01-06 19:59:19 UTC
patch added to qt-copy and for 11.2, queueing for 11.1.