Do not re-create font if it is not of TMPF_TRUETYPE

For !ttf and stretch==100 case, it was:
hfont = CreateFontIndirect(&lf);
TEXTMETRIC tm = ..;
if (!ttf) {
    DeleteObject(hfont);
    lf.lfWidth = tm.tmAveCharWidth;
    hfont = CreateFontIndirect(&lf);
}
Unless there is some special behavior for non-TrueType fonts I don't
know about, it looks to me like a 100% waste.

Change-Id: I864340e50591ba1d8006d1a80f36f6f06f2734b6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2015-02-15 02:45:46 +04:00
parent 202a3deec7
commit 840a26a9b9

View File

@ -1700,7 +1700,6 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
hfont = QWindowsFontDatabase::systemFont();
}
bool ttf = false;
int avWidth = 0;
BOOL res;
HGDIOBJ oldObj = SelectObject(data->hdc, hfont);
@ -1708,11 +1707,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
TEXTMETRIC tm;
res = GetTextMetrics(data->hdc, &tm);
avWidth = tm.tmAveCharWidth;
ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE;
SelectObject(data->hdc, oldObj);
if (!useDirectWrite) {
if (!ttf || request.stretch != 100) {
if (request.stretch != 100) {
DeleteObject(hfont);
if (!res)
qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);