Skip to content

Commit 61379d4

Browse files
Josh Faustashkulz
authored andcommitted
Fix OpenType fonts with cmap tables on Windows
Task-number: QTBUG-31656 Reviewed-by: Konstantin Ritt <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Change-Id: If941bddb6173b6bd93117ba5bd35fa4050f29e3d (cherry picked from qtbase/0a170be576153b84ee6249f1a2b7cbce1ef10d84)
1 parent 19f8b8e commit 61379d4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/gui/text/qfontengine_win.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,18 @@ bool QFontEngineWin::hasCFFTable() const
197197
return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR;
198198
}
199199

200+
bool QFontEngineWin::hasCMapTable() const
201+
{
202+
HDC hdc = shared_dc();
203+
SelectObject(hdc, hfont);
204+
return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR;
205+
}
206+
200207
void QFontEngineWin::getCMap()
201208
{
202-
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE);
209+
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
203210

204-
// TMPF_TRUETYPE is not set for fonts with CFF tables
205-
cffTable = !ttf && hasCFFTable();
211+
cffTable = hasCFFTable();
206212

207213
HDC hdc = shared_dc();
208214
SelectObject(hdc, hfont);
@@ -384,6 +390,7 @@ HGDIOBJ QFontEngineWin::selectDesignFont() const
384390
{
385391
LOGFONT f = logfont;
386392
f.lfHeight = unitsPerEm;
393+
f.lfWidth = 0;
387394
HFONT designFont = CreateFontIndirect(&f);
388395
return SelectObject(shared_dc(), designFont);
389396
}

src/gui/text/qfontengine_win_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class QFontEngineWin : public QFontEngine
147147

148148
private:
149149
bool hasCFFTable() const;
150+
bool hasCMapTable() const;
150151
QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
151152
QImage::Format mask_format);
152153

0 commit comments

Comments
 (0)