summaryrefslogtreecommitdiff
path: root/src/cairo-quartz-font.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2010-05-13 12:15:19 +0200
committerAndrea Canciani <ranma42@gmail.com>2010-05-17 22:01:50 +0200
commitf40e3b09a130a9ccbe310120fd5cfc7ad7828a4d (patch)
tree38045b7e7860c8ee47f5734a649f57783d53923a /src/cairo-quartz-font.c
parent1687e6169463947554f5476674a577e67e2c543b (diff)
downloadcairo-f40e3b09a130a9ccbe310120fd5cfc7ad7828a4d.tar.gz
quartz-font: Silence 0x0 CGContext warning
Silence Quartz complaints about operations on empty contexts: <Error>: CGContextSetFont: invalid context 0x0 <Error>: CGContextSetFontSize: invalid context 0x0 <Error>: CGContextSetTextMatrix: invalid context 0x0 <Error>: CGContextSetAlpha: invalid context 0x0 <Error>: CGContextShowGlyphsAtPoint: invalid context 0x0
Diffstat (limited to 'src/cairo-quartz-font.c')
-rw-r--r--src/cairo-quartz-font.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 74674ea55..2147cd3f6 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -673,43 +673,50 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
if (surface->base.status)
return surface->base.status;
- cgContext = CGBitmapContextCreate (surface->data,
- surface->width,
- surface->height,
- 8,
- surface->stride,
- NULL,
- kCGImageAlphaOnly);
-
- CGContextSetFont (cgContext, font_face->cgFont);
- CGContextSetFontSize (cgContext, 1.0);
- CGContextSetTextMatrix (cgContext, textMatrix);
-
- switch (font->base.options.antialias) {
- case CAIRO_ANTIALIAS_SUBPIXEL:
- CGContextSetShouldAntialias (cgContext, TRUE);
- CGContextSetShouldSmoothFonts (cgContext, TRUE);
- if (CGContextSetAllowsFontSmoothingPtr &&
- !CGContextGetAllowsFontSmoothingPtr (cgContext))
- CGContextSetAllowsFontSmoothingPtr (cgContext, TRUE);
- break;
- case CAIRO_ANTIALIAS_NONE:
- CGContextSetShouldAntialias (cgContext, FALSE);
- break;
- case CAIRO_ANTIALIAS_GRAY:
- CGContextSetShouldAntialias (cgContext, TRUE);
- CGContextSetShouldSmoothFonts (cgContext, FALSE);
- break;
- case CAIRO_ANTIALIAS_DEFAULT:
- default:
- /* Don't do anything */
- break;
- }
+ if (surface->width != 0 && surface->height != 0) {
+ cgContext = CGBitmapContextCreate (surface->data,
+ surface->width,
+ surface->height,
+ 8,
+ surface->stride,
+ NULL,
+ kCGImageAlphaOnly);
+
+ if (cgContext == NULL) {
+ cairo_surface_destroy (surface);
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ }
- CGContextSetAlpha (cgContext, 1.0);
- CGContextShowGlyphsAtPoint (cgContext, - glyphOrigin.x, - glyphOrigin.y, &glyph, 1);
+ CGContextSetFont (cgContext, font_face->cgFont);
+ CGContextSetFontSize (cgContext, 1.0);
+ CGContextSetTextMatrix (cgContext, textMatrix);
+
+ switch (font->base.options.antialias) {
+ case CAIRO_ANTIALIAS_SUBPIXEL:
+ CGContextSetShouldAntialias (cgContext, TRUE);
+ CGContextSetShouldSmoothFonts (cgContext, TRUE);
+ if (CGContextSetAllowsFontSmoothingPtr &&
+ !CGContextGetAllowsFontSmoothingPtr (cgContext))
+ CGContextSetAllowsFontSmoothingPtr (cgContext, TRUE);
+ break;
+ case CAIRO_ANTIALIAS_NONE:
+ CGContextSetShouldAntialias (cgContext, FALSE);
+ break;
+ case CAIRO_ANTIALIAS_GRAY:
+ CGContextSetShouldAntialias (cgContext, TRUE);
+ CGContextSetShouldSmoothFonts (cgContext, FALSE);
+ break;
+ case CAIRO_ANTIALIAS_DEFAULT:
+ default:
+ /* Don't do anything */
+ break;
+ }
- CGContextRelease (cgContext);
+ CGContextSetAlpha (cgContext, 1.0);
+ CGContextShowGlyphsAtPoint (cgContext, - glyphOrigin.x, - glyphOrigin.y, &glyph, 1);
+
+ CGContextRelease (cgContext);
+ }
cairo_surface_set_device_offset (&surface->base,
- glyphOrigin.x,