Windows DirectWrite: Improve error messages for font engine creation.

Fix up debug operator for QFontDef, add one for LOGFONT and output
both should creation fail.

Task-number: QTBUG-51260
Change-Id: I5cbcd392edd811c6b9470ddbb095d41a9185d208
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
bb10
Friedemann Kleint 2016-02-19 15:43:37 +01:00 committed by Simon Hausmann
parent a5ec7163f9
commit 1ffce57157
1 changed files with 24 additions and 7 deletions

View File

@ -634,11 +634,24 @@ QDebug operator<<(QDebug d, const QFontDef &def)
{
QDebugStateSaver saver(d);
d.nospace();
d << "Family=" << def.family << " Stylename=" << def.styleName
<< " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize
<< " styleHint=" << def.styleHint << " weight=" << def.weight
<< " stretch=" << def.stretch << " hintingPreference="
<< def.hintingPreference;
d.noquote();
d << "QFontDef(Family=\"" << def.family << '"';
if (!def.styleName.isEmpty())
d << ", stylename=" << def.styleName;
d << ", pointsize=" << def.pointSize << ", pixelsize=" << def.pixelSize
<< ", styleHint=" << def.styleHint << ", weight=" << def.weight
<< ", stretch=" << def.stretch << ", hintingPreference="
<< def.hintingPreference << ')';
return d;
}
QDebug operator<<(QDebug d, const LOGFONT &lf)
{
QDebugStateSaver saver(d);
d.nospace();
d.noquote();
d << "LOGFONT(\"" << QString::fromWCharArray(lf.lfFaceName)
<< "\", lfWidth=" << lf.lfWidth << ", lfHeight=" << lf.lfHeight << ')';
return d;
}
#endif // !QT_NO_DEBUG_STREAM
@ -1752,12 +1765,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
IDWriteFont *directWriteFont = 0;
HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont);
if (FAILED(hr)) {
qErrnoWarning("%s: CreateFontFromLOGFONT failed", __FUNCTION__);
const QString errorString = qt_error_string(int(GetLastError()));
qWarning().noquote().nospace() << "DirectWrite: CreateFontFromLOGFONT() failed ("
<< errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
} else {
IDWriteFontFace *directWriteFontFace = NULL;
hr = directWriteFont->CreateFontFace(&directWriteFontFace);
if (FAILED(hr)) {
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
const QString errorString = qt_error_string(int(GetLastError()));
qWarning().noquote() << "DirectWrite: CreateFontFace() failed ("
<< errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
} else {
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
request.pixelSize,