From 61379d481a1a9d646c812df010089c6d52d18f31 Mon Sep 17 00:00:00 2001 From: Josh Faust Date: Tue, 11 Jun 2013 00:12:01 +0530 Subject: Fix OpenType fonts with cmap tables on Windows Task-number: QTBUG-31656 Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll Change-Id: If941bddb6173b6bd93117ba5bd35fa4050f29e3d (cherry picked from qtbase/0a170be576153b84ee6249f1a2b7cbce1ef10d84) --- src/gui/text/qfontengine_win.cpp | 13 ++++++++++--- src/gui/text/qfontengine_win_p.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index befe37f143..9852b89072 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -197,12 +197,18 @@ bool QFontEngineWin::hasCFFTable() const return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; } +bool QFontEngineWin::hasCMapTable() const +{ + HDC hdc = shared_dc(); + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; +} + void QFontEngineWin::getCMap() { - ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE); + ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable(); - // TMPF_TRUETYPE is not set for fonts with CFF tables - cffTable = !ttf && hasCFFTable(); + cffTable = hasCFFTable(); HDC hdc = shared_dc(); SelectObject(hdc, hfont); @@ -384,6 +390,7 @@ HGDIOBJ QFontEngineWin::selectDesignFont() const { LOGFONT f = logfont; f.lfHeight = unitsPerEm; + f.lfWidth = 0; HFONT designFont = CreateFontIndirect(&f); return SelectObject(shared_dc(), designFont); } diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h index a56cd2c78c..ba6aa020db 100644 --- a/src/gui/text/qfontengine_win_p.h +++ b/src/gui/text/qfontengine_win_p.h @@ -147,6 +147,7 @@ public: private: bool hasCFFTable() const; + bool hasCMapTable() const; QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform, QImage::Format mask_format); -- cgit v1.2.3