summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/windows
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-12-13 08:03:38 +0100
committerAapo Keskimolo <aapo.keskimolo@qt.io>2017-12-14 09:01:45 +0000
commitff2ae36551b75b2c8a2d1f73e4d1e956b4eadb62 (patch)
treeb9bf50f738fe0674e10332f83ab0b67358ef8c88 /src/platformsupport/fontdatabases/windows
parent99b12531013516c060eed60157f8b0be5eafa1e5 (diff)
Windows: Support application fonts as fallbacks
In order to support the generated EUDC.TTE font for End-User Defined Characters on Windows, we need to allow fallback fonts which are not part of the default font collection. This is the same as change 21c7421d4e86b6048f9c2c7a9a81ec4ff1ed278c, but adapted to the fallback font code path. Without this change, the EUDC file would still be loaded, but it would be loaded through the GDI fallback, and we would display an error message on the console. Task-number: QTBUG-44594 Change-Id: Id2404228c7fd345523e4e5c99f31862e256930e3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/platformsupport/fontdatabases/windows')
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp
index a337332b53..584e4db05d 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp
@@ -1267,31 +1267,36 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
lf.lfFaceName[nameSubstituteLength] = 0;
}
- IDWriteFont *directWriteFont = 0;
- HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont);
- if (FAILED(hr)) {
- qWarning("%s: %s", __FUNCTION__,
- qPrintable(msgDirectWriteFunctionFailed(hr, "CreateFontFromLOGFONT", fam, nameSubstitute)));
+ HFONT hfont = CreateFontIndirect(&lf);
+ if (hfont == nullptr) {
+ qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
} else {
- Q_ASSERT(directWriteFont);
- IDWriteFontFace *directWriteFontFace = NULL;
- HRESULT hr = directWriteFont->CreateFontFace(&directWriteFontFace);
+ HGDIOBJ oldFont = SelectObject(data->hdc, hfont);
+
+ IDWriteFontFace *directWriteFontFace = nullptr;
+ QWindowsFontEngineDirectWrite *fedw = nullptr;
+ HRESULT hr = data->directWriteGdiInterop->CreateFontFaceFromHdc(data->hdc, &directWriteFontFace);
if (SUCCEEDED(hr)) {
Q_ASSERT(directWriteFontFace);
- QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
- fontEngine->fontDef.pixelSize,
- data);
+ fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
+ fontEngine->fontDef.pixelSize,
+ data);
fedw->fontDef.weight = fontEngine->fontDef.weight;
if (fontEngine->fontDef.style > QFont::StyleNormal)
fedw->fontDef.style = fontEngine->fontDef.style;
fedw->fontDef.family = fam;
fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
fedw->fontDef.stretch = fontEngine->fontDef.stretch;
- return fedw;
} else {
qWarning("%s: %s", __FUNCTION__,
qPrintable(msgDirectWriteFunctionFailed(hr, "CreateFontFace", fam, nameSubstitute)));
}
+
+ SelectObject(data->hdc, oldFont);
+ DeleteObject(hfont);
+
+ if (fedw != nullptr)
+ return fedw;
}
}
#endif