Add virtual function to QFontEngine report if outlines are reliable
GetGlyphOutline fails for ttf fonts with embedded bitmaps. This results in distancefield rendering not rendering glyphs (for the failed paths). We need to fall back to texture rendering if this is the case. Change-Id: Ibdf7dc5c1d34f513c436f88fabbdcc4089bb6fef Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>bb10
parent
c76d8c42b2
commit
2bc619c30e
|
|
@ -1335,6 +1335,15 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami
|
|||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some font engines like the windows font engine
|
||||
* can not reliable create outline paths
|
||||
*/
|
||||
bool QFontEngine::hasUnreliableGlyphOutline() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
|
||||
{
|
||||
if (glyphs.numGlyphs >= 1) {
|
||||
|
|
|
|||
|
|
@ -251,6 +251,8 @@ public:
|
|||
|
||||
static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily);
|
||||
|
||||
virtual bool hasUnreliableGlyphOutline() const;
|
||||
|
||||
enum HintStyle {
|
||||
HintNone,
|
||||
HintLight,
|
||||
|
|
|
|||
|
|
@ -169,6 +169,20 @@ bool QWindowsFontEngine::hasCMapTable() const
|
|||
return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR;
|
||||
}
|
||||
|
||||
bool QWindowsFontEngine::hasGlyfTable() const
|
||||
{
|
||||
HDC hdc = m_fontEngineData->hdc;
|
||||
SelectObject(hdc, hfont);
|
||||
return GetFontData(hdc, MAKE_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR;
|
||||
}
|
||||
|
||||
bool QWindowsFontEngine::hasEbdtTable() const
|
||||
{
|
||||
HDC hdc = m_fontEngineData->hdc;
|
||||
SelectObject(hdc, hfont);
|
||||
return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR;
|
||||
}
|
||||
|
||||
void QWindowsFontEngine::getCMap()
|
||||
{
|
||||
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
|
||||
|
|
@ -308,6 +322,8 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
|||
userData.insert(QStringLiteral("hFont"), QVariant::fromValue(hfont));
|
||||
userData.insert(QStringLiteral("trueType"), QVariant(bool(ttf)));
|
||||
setUserData(userData);
|
||||
|
||||
hasUnreliableOutline = hasGlyfTable() && hasEbdtTable();
|
||||
}
|
||||
|
||||
QWindowsFontEngine::~QWindowsFontEngine()
|
||||
|
|
@ -662,6 +678,11 @@ void QWindowsFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qre
|
|||
}
|
||||
#endif // Q_CC_MINGW
|
||||
|
||||
bool QWindowsFontEngine::hasUnreliableGlyphOutline() const
|
||||
{
|
||||
return hasUnreliableOutline;
|
||||
}
|
||||
|
||||
qreal QWindowsFontEngine::minLeftBearing() const
|
||||
{
|
||||
if (lbearing == SHRT_MIN)
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ public:
|
|||
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
|
||||
#endif
|
||||
|
||||
bool hasUnreliableGlyphOutline() const Q_DECL_OVERRIDE;
|
||||
|
||||
int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs) const;
|
||||
void getCMap();
|
||||
|
||||
|
|
@ -136,6 +138,8 @@ private:
|
|||
QImage::Format mask_format);
|
||||
bool hasCFFTable() const;
|
||||
bool hasCMapTable() const;
|
||||
bool hasGlyfTable() const;
|
||||
bool hasEbdtTable() const;
|
||||
|
||||
const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
|
||||
|
||||
|
|
@ -146,6 +150,7 @@ private:
|
|||
uint stockFont : 1;
|
||||
uint ttf : 1;
|
||||
uint hasOutline : 1;
|
||||
uint hasUnreliableOutline : 1;
|
||||
uint cffTable : 1;
|
||||
TEXTMETRIC tm;
|
||||
int lw;
|
||||
|
|
|
|||
Loading…
Reference in New Issue