Fix crash when trying to create paths for color-glyphs (Emoji) on Mac
CoreText segfaults when creating paths for color-glyphs: 0 0x00007fff8fd41e69 in TFont::FindColourBitmapForGlyph () 1 0x00007fff8fd417ac in TFont::CreatePathForGlyph () 2 0x000000010567d1af in QCoreTextFontEngine::addGlyphsToPath (...) So we shortcut the code-path, since we don't support Emoji yet anyways. Task-number: QTBUG-28615 Change-Id: Ife16ae4959077d9eaaf6ea5cd1f27a4e2e01e7f5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
parent
9941bf5118
commit
e11cf63b0b
@ -69,7 +69,8 @@ public:
|
|||||||
enum Type {
|
enum Type {
|
||||||
Raster_RGBMask,
|
Raster_RGBMask,
|
||||||
Raster_A8,
|
Raster_A8,
|
||||||
Raster_Mono
|
Raster_Mono,
|
||||||
|
Raster_ARGB
|
||||||
};
|
};
|
||||||
|
|
||||||
QFontEngineGlyphCache(const QTransform &matrix, Type type) : m_transform(matrix), m_type(type) { }
|
QFontEngineGlyphCache(const QTransform &matrix, Type type) : m_transform(matrix), m_type(type) { }
|
||||||
|
@ -149,8 +149,6 @@ void QCoreTextFontEngine::init()
|
|||||||
Q_ASSERT(ctfont != NULL);
|
Q_ASSERT(ctfont != NULL);
|
||||||
Q_ASSERT(cgFont != NULL);
|
Q_ASSERT(cgFont != NULL);
|
||||||
|
|
||||||
glyphFormat = defaultGlyphFormat;
|
|
||||||
|
|
||||||
QCFString family = CTFontCopyFamilyName(ctfont);
|
QCFString family = CTFontCopyFamilyName(ctfont);
|
||||||
fontDef.family = family;
|
fontDef.family = family;
|
||||||
|
|
||||||
@ -159,6 +157,14 @@ void QCoreTextFontEngine::init()
|
|||||||
|
|
||||||
synthesisFlags = 0;
|
synthesisFlags = 0;
|
||||||
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont);
|
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont);
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
|
if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait))
|
||||||
|
glyphFormat = QFontEngineGlyphCache::Raster_ARGB;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
glyphFormat = defaultGlyphFormat;
|
||||||
|
|
||||||
if (traits & kCTFontItalicTrait)
|
if (traits & kCTFontItalicTrait)
|
||||||
fontDef.style = QFont::StyleItalic;
|
fontDef.style = QFont::StyleItalic;
|
||||||
|
|
||||||
@ -422,6 +428,9 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
|
|||||||
void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
|
void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
|
||||||
QPainterPath *path, QTextItem::RenderFlags)
|
QPainterPath *path, QTextItem::RenderFlags)
|
||||||
{
|
{
|
||||||
|
if (glyphFormat == QFontEngineGlyphCache::Raster_ARGB)
|
||||||
|
return; // We can't convert color-glyphs to path
|
||||||
|
|
||||||
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
|
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
|
||||||
cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
|
cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
|
||||||
|
|
||||||
|
@ -108,6 +108,21 @@ public:
|
|||||||
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
|
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
|
||||||
virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; }
|
virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; }
|
||||||
|
|
||||||
|
static bool supportsColorGlyphs()
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_IOS)
|
||||||
|
return true;
|
||||||
|
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||||
|
return &CTFontDrawGlyphs;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int antialiasingThreshold;
|
static int antialiasingThreshold;
|
||||||
static QFontEngineGlyphCache::Type defaultGlyphFormat;
|
static QFontEngineGlyphCache::Type defaultGlyphFormat;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user