Simplify QWindowsFontDatabase::createEngine()
Reduce code duplication and improve readability. Change-Id: Idf53c80077daa9bac03a72acfd2b6c7e3a24ad97 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
parent
af1a99ebb9
commit
4d54fe8d02
@ -1735,13 +1735,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
|
|||||||
|
|
||||||
QFontEngine *fe = 0;
|
QFontEngine *fe = 0;
|
||||||
if (!useDirectWrite) {
|
if (!useDirectWrite) {
|
||||||
HFONT hfont = CreateFontIndirect(&lf);
|
QWindowsFontEngine *few = new QWindowsFontEngine(request.family, lf, data);
|
||||||
if (!hfont) {
|
|
||||||
qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
|
|
||||||
hfont = QWindowsFontDatabase::systemFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, lf, data);
|
|
||||||
if (preferClearTypeAA)
|
if (preferClearTypeAA)
|
||||||
few->glyphFormat = QFontEngine::Format_A32;
|
few->glyphFormat = QFontEngine::Format_A32;
|
||||||
few->initFontInfo(request, dpi);
|
few->initFontInfo(request, dpi);
|
||||||
|
@ -264,12 +264,12 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
||||||
HFONT _hfont, LOGFONT lf,
|
LOGFONT lf,
|
||||||
const QSharedPointer<QWindowsFontEngineData> &fontEngineData)
|
const QSharedPointer<QWindowsFontEngineData> &fontEngineData)
|
||||||
: QFontEngine(Win),
|
: QFontEngine(Win),
|
||||||
m_fontEngineData(fontEngineData),
|
m_fontEngineData(fontEngineData),
|
||||||
_name(name),
|
_name(name),
|
||||||
hfont(_hfont),
|
hfont(0),
|
||||||
m_logfont(lf),
|
m_logfont(lf),
|
||||||
ttf(0),
|
ttf(0),
|
||||||
hasOutline(0),
|
hasOutline(0),
|
||||||
@ -286,6 +286,12 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
|||||||
designAdvancesSize(0)
|
designAdvancesSize(0)
|
||||||
{
|
{
|
||||||
qCDebug(lcQpaFonts) << __FUNCTION__ << name << lf.lfHeight;
|
qCDebug(lcQpaFonts) << __FUNCTION__ << name << lf.lfHeight;
|
||||||
|
hfont = CreateFontIndirect(&m_logfont);
|
||||||
|
if (!hfont) {
|
||||||
|
qErrnoWarning("%s: CreateFontIndirect failed for family '%s'", __FUNCTION__, qPrintable(name));
|
||||||
|
hfont = QWindowsFontDatabase::systemFont();
|
||||||
|
}
|
||||||
|
|
||||||
HDC hdc = m_fontEngineData->hdc;
|
HDC hdc = m_fontEngineData->hdc;
|
||||||
SelectObject(hdc, hfont);
|
SelectObject(hdc, hfont);
|
||||||
const BOOL res = GetTextMetrics(hdc, &tm);
|
const BOOL res = GetTextMetrics(hdc, &tm);
|
||||||
@ -1361,11 +1367,8 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
|
|
||||||
// Get here if original font is not DirectWrite or DirectWrite creation failed for some
|
// Get here if original font is not DirectWrite or DirectWrite creation failed for some
|
||||||
// reason
|
// reason
|
||||||
HFONT hfont = CreateFontIndirect(&lf);
|
|
||||||
if (hfont == 0)
|
|
||||||
hfont = QWindowsFontDatabase::systemFont();
|
|
||||||
|
|
||||||
return new QWindowsFontEngine(fam, hfont, lf, data);
|
return new QWindowsFontEngine(fam, lf, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const
|
bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const
|
||||||
|
@ -63,7 +63,7 @@ class QWindowsFontEngine : public QFontEngine
|
|||||||
friend class QWindowsMultiFontEngine;
|
friend class QWindowsMultiFontEngine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QWindowsFontEngine(const QString &name, HFONT hfont, LOGFONT lf,
|
QWindowsFontEngine(const QString &name, LOGFONT lf,
|
||||||
const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
|
const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
|
||||||
|
|
||||||
~QWindowsFontEngine();
|
~QWindowsFontEngine();
|
||||||
@ -137,7 +137,7 @@ private:
|
|||||||
|
|
||||||
const QString _name;
|
const QString _name;
|
||||||
QString uniqueFamilyName;
|
QString uniqueFamilyName;
|
||||||
const HFONT hfont;
|
HFONT hfont;
|
||||||
const LOGFONT m_logfont;
|
const LOGFONT m_logfont;
|
||||||
uint ttf : 1;
|
uint ttf : 1;
|
||||||
uint hasOutline : 1;
|
uint hasOutline : 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user