diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2012-12-21 14:23:28 (GMT) |
---|---|---|
committer | Ashish Kulkarni <kulkarni.ashish@gmail.com> | 2014-12-13 17:28:39 (GMT) |
commit | 19f8b8ebc144555f53f69d8a0230d24a91384454 (patch) | |
tree | 4573db7e66b5b99d991337ccd4b7f2ccaa1ff681 | |
parent | 3985dfb6e6c7fd89ebbccc9a238fe02169e0cbc0 (diff) | |
download | Qt-19f8b8ebc144555f53f69d8a0230d24a91384454.zip Qt-19f8b8ebc144555f53f69d8a0230d24a91384454.tar.gz Qt-19f8b8ebc144555f53f69d8a0230d24a91384454.tar.bz2 |
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
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Change-Id: I1e084f7e9dbd0bccb9b1ff4de2eaf65d6a5f9f1e
(cherry picked from qtbase/dde09c429ae8b7ad0df4e4b36b8459d2b85a1219)
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r-- | src/gui/text/qfontengine_win.cpp | 13 | ||||
-rw-r--r-- | src/gui/text/qfontengine_win_p.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index f2881ca..befe37f 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -190,9 +190,20 @@ static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc) return otm; } +bool QFontEngineWin::hasCFFTable() const +{ + HDC hdc = shared_dc(); + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; +} + void QFontEngineWin::getCMap() { ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE); + + // TMPF_TRUETYPE is not set for fonts with CFF tables + cffTable = !ttf && hasCFFTable(); + HDC hdc = shared_dc(); SelectObject(hdc, hfont); bool symb = false; @@ -1072,7 +1083,7 @@ void QFontEngineWin::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - if (!ttf) + if (!ttf && !cffTable) return false; HDC hdc = shared_dc(); SelectObject(hdc, hfont); diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h index 2b5ad4e..a56cd2c 100644 --- a/src/gui/text/qfontengine_win_p.h +++ b/src/gui/text/qfontengine_win_p.h @@ -126,6 +126,7 @@ public: uint stockFont : 1; uint ttf : 1; uint hasOutline : 1; + uint cffTable : 1; TEXTMETRIC tm; int lw; const unsigned char *cmap; @@ -145,6 +146,7 @@ public: mutable int designAdvancesSize; private: + bool hasCFFTable() const; QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform, QImage::Format mask_format); |