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
21c7421d4e, 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>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2017-12-13 08:03:38 +01:00 committed by Aapo Keskimolo
parent 99b1253101
commit ff2ae36551

View File

@ -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