QFontEngine: Fix cache_cost might be not initialized

Change-Id: I4cf4de5797e6623a71593e8f382496188e3abac8
Reviewed-by: jian liang <jianliang79@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2013-04-12 06:13:13 +03:00 committed by The Qt Project
parent 112b31bed6
commit 1f3a67e870
4 changed files with 5 additions and 0 deletions

View File

@ -199,6 +199,7 @@ QFontEngine::QFontEngine()
font_(0), font_destroy_func(0),
face_(0), face_destroy_func(0)
{
cache_cost = 0;
fsType = 0;
symbol = false;

View File

@ -688,6 +688,7 @@ void QFontEngineMultiQPA::init(QFontEngine *fe)
fe->ref.ref();
fontDef = engines[0]->fontDef;
setObjectName(QStringLiteral("QFontEngineMultiQPA"));
cache_cost = fe->cache_cost;
}
void QFontEngineMultiQPA::loadEngine(int at)

View File

@ -189,6 +189,8 @@ void QCoreTextFontEngine::init()
avgCharWidth = QFixed::fromReal(width * fontDef.pixelSize / emSize);
} else
avgCharWidth = QFontEngine::averageCharWidth();
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
}
bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,

View File

@ -220,6 +220,7 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di
fontDef.pixelSize = pixelSize;
collectMetrics();
cache_cost = (m_ascent.toInt() + m_descent.toInt()) * m_xHeight.toInt() * 2000;
}
QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite()