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:
parent
202a3deec7
commit
840a26a9b9
@ -1700,7 +1700,6 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
|
|||||||
hfont = QWindowsFontDatabase::systemFont();
|
hfont = QWindowsFontDatabase::systemFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ttf = false;
|
|
||||||
int avWidth = 0;
|
int avWidth = 0;
|
||||||
BOOL res;
|
BOOL res;
|
||||||
HGDIOBJ oldObj = SelectObject(data->hdc, hfont);
|
HGDIOBJ oldObj = SelectObject(data->hdc, hfont);
|
||||||
@ -1708,11 +1707,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
|
|||||||
TEXTMETRIC tm;
|
TEXTMETRIC tm;
|
||||||
res = GetTextMetrics(data->hdc, &tm);
|
res = GetTextMetrics(data->hdc, &tm);
|
||||||
avWidth = tm.tmAveCharWidth;
|
avWidth = tm.tmAveCharWidth;
|
||||||
ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE;
|
|
||||||
SelectObject(data->hdc, oldObj);
|
SelectObject(data->hdc, oldObj);
|
||||||
|
|
||||||
if (!useDirectWrite) {
|
if (!useDirectWrite) {
|
||||||
if (!ttf || request.stretch != 100) {
|
if (request.stretch != 100) {
|
||||||
DeleteObject(hfont);
|
DeleteObject(hfont);
|
||||||
if (!res)
|
if (!res)
|
||||||
qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);
|
qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);
|
||||||
|
Loading…
Reference in New Issue
Block a user