From dde09c429ae8b7ad0df4e4b36b8459d2b85a1219 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 21 Dec 2012 15:23:28 +0100 Subject: Make distance fields rendering work with Opentype CFF fonts If the font has a CFF table, GDI will not label it as TMPF_TRUETYPE, however, we can still use GetFontData to get the SFNT tables. This is required to get the maxp table which contains the glyph count, which is required to use the font with the distance-field renderer. Task-number: QTBUG-28746 Change-Id: I3ca1e3d96ea53c453e6fa422b33d1f1f5050a82c Reviewed-by: Konstantin Ritt --- src/plugins/platforms/windows/qwindowsfontengine.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows/qwindowsfontengine.cpp') diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 578a0cd20b..e51d6d4e7e 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -155,9 +155,20 @@ static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc) return otm; } +bool QWindowsFontEngine::hasCFFTable() const +{ + HDC hdc = m_fontEngineData->hdc; + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; +} + void QWindowsFontEngine::getCMap() { ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE); + + // TMPF_TRUETYPE is not set for fonts with CFF tables + cffTable = !ttf && hasCFFTable(); + HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); bool symb = false; @@ -1041,7 +1052,7 @@ void QWindowsFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gly bool QWindowsFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - if (!ttf) + if (!ttf && !cffTable) return false; HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); -- cgit v1.2.3