Bugzilla – Bug 448012
[Fix_is_Ready:11.1] Qt4 uses Nimbus Sans L as "Sans Serif" font
Last modified: 2009-01-06 19:59:19 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.
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?
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".
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",
Another option is changing /etc/fonts/conf.d/30-metric-aliases.conf
*** Bug 461181 has been marked as a duplicate of this bug. ***
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
patch added to qt-copy and for 11.2, queueing for 11.1.