diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-09-26 10:19:37 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2019-10-21 13:56:27 +0000 |
commit | e1e4b1b780485f7d74ff8da997730a00e4a79a1f (patch) | |
tree | 0d9b008e4a765192806bfe83bf121470b1a3a8f7 | |
parent | 197dfcd36fc0602282fb24b58c44edc29f0efc19 (diff) |
Remove DirectWrite warning when loading bitmap fonts
We use DirectWrite to determine whether a font is a color font
or not, so all fonts go through DirectWrite initially. However,
the load call will fail for bitmap fonts, causing us to output
lots of pointless warnings each time such a font was in use.
Instead, we only output this warning if we actually plan to
load the font through DirectWrite later. If the load fails,
we can assume it is not a color font and do not need to output
any warning for this.
[ChangeLog][Windows][Text] Removed confusing DirectWrite warning
when loading bitmap fonts.
Task-number: QTBUG-57180
Change-Id: Iaac8117745ef05a1dff23b346dbe0c6dbfb315f7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit c4a524f3a129ad9ab6d08cd8de2dc917e3d78fc5)
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r-- | src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 9e6e5d88c7..c456f01b28 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1961,13 +1961,13 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q } else { HGDIOBJ oldFont = SelectObject(data->hdc, hfont); + const QFont::HintingPreference hintingPreference = + static_cast<QFont::HintingPreference>(request.hintingPreference); + bool useDw = useDirectWrite(hintingPreference, fam); + IDWriteFontFace *directWriteFontFace = NULL; HRESULT hr = data->directWriteGdiInterop->CreateFontFaceFromHdc(data->hdc, &directWriteFontFace); - if (FAILED(hr)) { - const QString errorString = qt_error_string(int(hr)); - qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed (" - << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; - } else { + if (SUCCEEDED(hr)) { bool isColorFont = false; #if defined(QT_USE_DIRECTWRITE2) IDWriteFontFace2 *directWriteFontFace2 = nullptr; @@ -1977,9 +1977,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q isColorFont = directWriteFontFace2->GetPaletteEntryCount() > 0; } #endif - const QFont::HintingPreference hintingPreference = - static_cast<QFont::HintingPreference>(request.hintingPreference); - const bool useDw = useDirectWrite(hintingPreference, fam, isColorFont); + useDw = useDw || useDirectWrite(hintingPreference, fam, isColorFont); qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize << "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont << dpi << "dpi" << "useDirectWrite=" << useDw; @@ -2001,6 +1999,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q } else { directWriteFontFace->Release(); } + } else if (useDw) { + const QString errorString = qt_error_string(int(hr)); + qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed (" + << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; } SelectObject(data->hdc, oldFont); |