path: root/src/platformsupport
diff options
authorTor Arne Vestbø <>2014-04-30 15:26:57 +0200
committerThe Qt Project <>2014-05-12 13:44:59 +0200
commit5a060a5ad322629f1a1ee0c850db94932543fee5 (patch)
treedd5ab1b39a365cba2f6d47fc53b3e75489925a66 /src/platformsupport
parenta669564597f1d9aebe6f992d890b730c7be10f6f (diff)
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 <>
Diffstat (limited to 'src/platformsupport')
1 files changed, 5 insertions, 0 deletions
diff --git a/src/platformsupport/fontdatabases/mac/ b/src/platformsupport/fontdatabases/mac/
index 0460f11139..6e2c8a2a9a 100644
--- a/src/platformsupport/fontdatabases/mac/
+++ b/src/platformsupport/fontdatabases/mac/
@@ -559,6 +559,9 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
QImage im(br.width.ceil().toInt(), br.height.ceil().toInt(), imageFormat);
+ if (!im.width() || !im.height())
+ return im;
#ifndef Q_OS_IOS
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
@@ -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;
CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(),
8, im.bytesPerLine(), colorspace,
+ Q_ASSERT(ctx);
CGContextSetFontSize(ctx, fontDef.pixelSize);
CGContextSetShouldAntialias(ctx, (aa || fontDef.pointSize > antialiasingThreshold)
&& !(fontDef.styleStrategy & QFont::NoAntialias));