diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2008-03-08 15:16:05 -0800 |
---|---|---|
committer | Vladimir Vukicevic <vladimir@sleet.vlad1.com> | 2008-03-08 15:16:05 -0800 |
commit | 091df2c59b6dbd53a748955db359443d5d445ba4 (patch) | |
tree | 0afe5bcd8a7ed923a412d942d3b5de04e72f48c0 /src/cairo-quartz-surface.c | |
parent | 4f7ac14b8fdafd9fa85e797fb6e4c974788f70fc (diff) |
[quartz] properly honor text antialiasing modes in show_glyphs
Diffstat (limited to 'src/cairo-quartz-surface.c')
-rw-r--r-- | src/cairo-quartz-surface.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 183347d8..9f57595c 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -107,6 +107,10 @@ static void (*CGContextClipToMaskPtr) (CGContextRef, CGRect, CGImageRef) = NULL; /* Only present in 10.5+ */ static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL; static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL; +static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL; +static void (*CGContextSetShouldSmoothFontsPtr) (CGContextRef, bool) = NULL; +static void (*CGContextGetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL; +static void (*CGContextGetShouldSmoothFontsPtr) (CGContextRef, bool) = NULL; static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE; @@ -134,6 +138,10 @@ static void quartz_ensure_symbols(void) CGContextClipToMaskPtr = dlsym(RTLD_DEFAULT, "CGContextClipToMask"); CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage"); CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType"); + CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts"); + CGContextSetShouldSmoothFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldSmoothFonts"); + CGContextGetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldAntialiasFonts"); + CGContextGetShouldSmoothFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldSmoothFonts"); _cairo_quartz_symbol_lookup_done = TRUE; } @@ -1614,11 +1622,11 @@ _cairo_quartz_surface_stroke (void *abstract_surface, #if CAIRO_HAS_ATSUI_FONT static cairo_int_status_t _cairo_quartz_surface_show_glyphs (void *abstract_surface, - cairo_operator_t op, - cairo_pattern_t *source, - cairo_glyph_t *glyphs, - int num_glyphs, - cairo_scaled_font_t *scaled_font) + cairo_operator_t op, + cairo_pattern_t *source, + cairo_glyph_t *glyphs, + int num_glyphs, + cairo_scaled_font_t *scaled_font) { CGAffineTransform textTransform, ctm; #define STATIC_BUF_SIZE 64 @@ -1669,6 +1677,23 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface, CGContextSetFont (surface->cgContext, cgfref); CGContextSetFontSize (surface->cgContext, 1.0); + if (CGContextSetShouldAntialiasFontsPtr) { + switch (scaled_font->options.antialias) { + case CAIRO_ANTIALIAS_SUBPIXEL: + CGContextSetShouldAntialiasFontsPtr (surface->cgContext, TRUE); + CGContextSetShouldSmoothFontsPtr (surface->cgContext, TRUE); + break; + case CAIRO_ANTIALIAS_NONE: + CGContextSetShouldAntialiasFontsPtr (surface->cgContext, FALSE); + break; + case CAIRO_ANTIALIAS_GRAY: + case CAIRO_ANTIALIAS_DEFAULT: + CGContextSetShouldAntialiasFontsPtr (surface->cgContext, TRUE); + CGContextSetShouldSmoothFontsPtr (surface->cgContext, FALSE); + break; + } + } + if (num_glyphs > STATIC_BUF_SIZE) { cg_glyphs = (CGGlyph*) _cairo_malloc_ab (num_glyphs, sizeof(CGGlyph)); if (cg_glyphs == NULL) { |