[QWindowsFont*] Unify HFONT fallbacks
In case CreateFontIndirect() call fails, always fallback to a better stock font provided by Windows (apparently, it is DEFAULT_GUI_FONT). Change-Id: Ib78fe0d21ba4fccbba1152b81ed87c010e1220e0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
parent
01203a94b5
commit
7997e56a2e
@ -1422,7 +1422,7 @@ void QWindowsFontDatabase::refUniqueFont(const QString &uniqueFont)
|
||||
|
||||
HFONT QWindowsFontDatabase::systemFont()
|
||||
{
|
||||
static const HFONT stock_sysfont = (HFONT)GetStockObject(SYSTEM_FONT);
|
||||
static const HFONT stock_sysfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
||||
return stock_sysfont;
|
||||
}
|
||||
|
||||
@ -1706,13 +1706,8 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
|
||||
qErrnoWarning("%s: CreateFontIndirect with stretch failed", __FUNCTION__);
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WINCE
|
||||
if (hfont == 0)
|
||||
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
|
||||
#else
|
||||
if (hfont == 0)
|
||||
hfont = (HFONT)GetStockObject(SYSTEM_FONT);
|
||||
#endif
|
||||
hfont = QWindowsFontDatabase::systemFont();
|
||||
}
|
||||
|
||||
#if !defined(QT_NO_DIRECTWRITE)
|
||||
@ -1782,7 +1777,7 @@ static inline int verticalDPI()
|
||||
QFont QWindowsFontDatabase::systemDefaultFont()
|
||||
{
|
||||
LOGFONT lf;
|
||||
GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
|
||||
GetObject(QWindowsFontDatabase::systemFont(), sizeof(lf), &lf);
|
||||
QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(lf);
|
||||
// "MS Shell Dlg 2" is the correct system font >= Win2k
|
||||
if (systemFont.family() == QLatin1String("MS Shell Dlg"))
|
||||
|
@ -322,7 +322,7 @@ QWindowsFontEngine::~QWindowsFontEngine()
|
||||
free(widthCache);
|
||||
|
||||
// make sure we aren't by accident still selected
|
||||
SelectObject(m_fontEngineData->hdc, (HFONT)GetStockObject(SYSTEM_FONT));
|
||||
SelectObject(m_fontEngineData->hdc, QWindowsFontDatabase::systemFont());
|
||||
|
||||
if (!DeleteObject(hfont))
|
||||
qErrnoWarning("%s: QFontEngineWin: failed to delete font...", __FUNCTION__);
|
||||
@ -1363,7 +1363,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
||||
// reason
|
||||
HFONT hfont = CreateFontIndirect(&lf);
|
||||
if (hfont == 0)
|
||||
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
|
||||
hfont = QWindowsFontDatabase::systemFont();
|
||||
|
||||
return new QWindowsFontEngine(fam, hfont, lf, data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user