diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-04-30 15:26:57 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-12 13:44:59 +0200 |
commit | 5a060a5ad322629f1a1ee0c850db94932543fee5 (patch) | |
tree | dd5ab1b39a365cba2f6d47fc53b3e75489925a66 /src/platformsupport | |
parent | a669564597f1d9aebe6f992d890b730c7be10f6f (diff) | |
download | qtbase-5a060a5ad322629f1a1ee0c850db94932543fee5.tar.gz |
CoreText: Prevent creation of CGContext for glyphs with empty bounding box
If the alphaMapBoundingBox of a glyph is empty we don't want to create
a CGBitmapContext on it, as that will fail, and any further operations
on the invalid context will result in possibly fatal errors from CG.
This issue can be observed when drawing some glyphs of the Apple Color
Emoji font.
Change-Id: Ia45ba858b5fb6afa91e6d686a9c55e350d4095f3
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 0460f11139..6e2c8a2a9a 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -559,6 +559,9 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition QImage im(br.width.ceil().toInt(), br.height.ceil().toInt(), imageFormat); im.fill(0); + if (!im.width() || !im.height()) + return im; + #ifndef Q_OS_IOS CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); #else @@ -568,9 +571,11 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version cgflags |= kCGBitmapByteOrder32Host; #endif + CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(), 8, im.bytesPerLine(), colorspace, cgflags); + Q_ASSERT(ctx); CGContextSetFontSize(ctx, fontDef.pixelSize); CGContextSetShouldAntialias(ctx, (aa || fontDef.pointSize > antialiasingThreshold) && !(fontDef.styleStrategy & QFont::NoAntialias)); |