summaryrefslogtreecommitdiffstats
path: root/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-16 14:41:47 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-16 20:20:26 +0200
commit2f5695bed5660e32a41786d8b9ab6b4b0775caf1 (patch)
tree9d78961aba47d6093a19d604b49b21bf89149439 /src/gui/text/windows/qwindowsfontenginedirectwrite.cpp
parent874c8c56a4883383e49a1e59262113f8eb29486f (diff)
Fix printing with unhinted fonts
On high-dpi displays or when you explicitly select an unhinted font, we pick a DirectWrite font engine. This hit an uncovered code path on Windows, because we relied on being able to get the HFONT from the font engine. To fix this, we introduce an alternative code path which gets the HFONT based on the DirectWrite font when this font engine is active. [ChangeLog][Windows] Fixed an issue where the characters in printed text would look too small. Pick-to: 6.1 6.2 Fixes: QTBUG-95720 Change-Id: Ifd609e92512e1f25f0ee2aace35cb5ccedf09030 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text/windows/qwindowsfontenginedirectwrite.cpp')
-rw-r--r--src/gui/text/windows/qwindowsfontenginedirectwrite.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp
index 0dac9769ef..55aab15132 100644
--- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp
@@ -337,6 +337,22 @@ QString QWindowsFontEngineDirectWrite::filenameFromFontFile(IDWriteFontFile *fon
return ret;
}
+HFONT QWindowsFontEngineDirectWrite::createHFONT() const
+{
+ if (m_fontEngineData == nullptr || m_directWriteFontFace == nullptr)
+ return NULL;
+
+ LOGFONT lf;
+ HRESULT hr = m_fontEngineData->directWriteGdiInterop->ConvertFontFaceToLOGFONT(m_directWriteFontFace,
+ &lf);
+ if (SUCCEEDED(hr)) {
+ lf.lfHeight = -qRound(fontDef.pixelSize);
+ return CreateFontIndirect(&lf);
+ } else {
+ return NULL;
+ }
+}
+
void QWindowsFontEngineDirectWrite::initializeHeightMetrics() const
{
DWRITE_FONT_METRICS metrics;