diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-10-09 14:59:43 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-10-09 15:00:59 (GMT) |
commit | 30bd59a1dec78e3b8bb9bbbc4f129663efa169a6 (patch) | |
tree | 967ef1c2b3416477d25b7a256490c271ab5259fc /src/gui/text/qfontdatabase_x11.cpp | |
parent | 45b8fa65b82bcdb82ddb2f515e551d2948baf36d (diff) | |
download | Qt-30bd59a1dec78e3b8bb9bbbc4f129663efa169a6.zip Qt-30bd59a1dec78e3b8bb9bbbc4f129663efa169a6.tar.gz Qt-30bd59a1dec78e3b8bb9bbbc4f129663efa169a6.tar.bz2 |
Fix printing bitmap fonts on X11 with FontConfig enabled
When FontConfig was enabled, bitmap fonts would often get a different
pixel size than the one we requested. Usually the size would only be
a pixel off, but this was especially visible when printing in highres
with bitmap fonts, because in those cases we would request a pixel size
which was computed based on the printer's high dpi.
The result was that all printed text with bitmap fonts would be really
really tiny. The fix falls back to using the XLFD font engine when
using bitmap fonts (when the returned pixel size is different from the
requested), because this engine scales the fonts for us. This will
cause bitmap fonts to be rendered without antialiasing.
Task-number: QTBUG-3620
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui/text/qfontdatabase_x11.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase_x11.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index ae93f90..382c4fe 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1204,9 +1204,9 @@ static void loadFontConfig() static void initializeDb(); -static void load(const QString &family = QString(), int script = -1) +static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false) { - if (X11->has_fontconfig) { + if (X11->has_fontconfig && !forceXLFD) { initializeDb(); return; } @@ -1784,7 +1784,7 @@ QFontEngine *QFontDatabase::loadXlfd(int screen, int script, const QFontDef &req QString family, foundry; QT_PREPEND_NAMESPACE(parseFontName)(families_and_foundries.at(i), foundry, family); FM_DEBUG("loadXlfd: >>>>>>>>>>>>>>trying to match '%s' encoding=%d", family.toLatin1().data(), force_encoding_id); - QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc); + QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc, QList<int>(), true); if (desc.family) break; } @@ -1847,23 +1847,26 @@ QFontEngine *QFontDatabase::loadXlfd(int screen, int script, const QFontDef &req } } else { QList<int> encodings; - if (desc.encoding) - encodings.append(int(desc.encoding->encoding)); + if (desc.encoding) { + if (desc.encoding->encoding >= 0) + encodings.append(int(desc.encoding->encoding)); + } if (desc.size) { // append all other encodings for the matched font for (int i = 0; i < desc.size->count; ++i) { QtFontEncoding *e = desc.size->encodings + i; - if (e == desc.encoding) - continue; + if (e == desc.encoding || e->encoding < 0) + continue; encodings.append(int(e->encoding)); } } // fill in the missing encodings const XlfdEncoding *enc = xlfd_encoding; for (; enc->name; ++enc) { - if (!encodings.contains(enc->id)) + if (!encodings.contains(enc->id) && enc->id >= 0) { encodings.append(enc->id); + } } #if defined(FONT_MATCH_DEBUG) @@ -1925,6 +1928,13 @@ void QFontDatabase::load(const QFontPrivate *d, int script) #ifndef QT_NO_FONTCONFIG } else if (X11->has_fontconfig) { fe = loadFc(d, script, req); + + if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) { + delete fe; + fe = loadXlfd(d->screen, script, req); + } + + #endif } else if (mainThread) { fe = loadXlfd(d->screen, script, req); |