diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-font-options.c | 35 | ||||
-rw-r--r-- | src/cairo-gstate.c | 2 | ||||
-rw-r--r-- | src/cairo-truetype-subset.c | 6 | ||||
-rw-r--r-- | src/cairoint.h | 4 | ||||
-rw-r--r-- | src/win32/cairo-dwrite-font.cpp | 38 | ||||
-rw-r--r-- | src/win32/cairo-win32-font.c | 8 | ||||
-rw-r--r-- | src/win32/cairo-win32-private.h | 4 |
7 files changed, 54 insertions, 43 deletions
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c index fa3d3c4e1..33ee617b8 100644 --- a/src/cairo-font-options.c +++ b/src/cairo-font-options.c @@ -105,6 +105,41 @@ _cairo_font_options_init_copy (cairo_font_options_t *options, } } +cairo_bool_t +_cairo_font_options_compare (const cairo_font_options_t *a, + const cairo_font_options_t *b) +{ + if (a->antialias != b->antialias || + a->subpixel_order != b->subpixel_order || + a->lcd_filter != b->lcd_filter || + a->hint_style != b->hint_style || + a->hint_metrics != b->hint_metrics || + a->round_glyph_positions != b->round_glyph_positions || + a->color_mode != b->color_mode || + a->palette_index != b->palette_index || + a->custom_palette_size != b->custom_palette_size) + { + return FALSE; + } + + if (a->variations && b->variations && strcmp (a->variations, b->variations) != 0) + return FALSE; + else if (a->variations != b->variations) + return FALSE; + + if (a->custom_palette && b->custom_palette && + memcmp (a->custom_palette, b->custom_palette, sizeof (cairo_palette_color_t) * a->custom_palette_size) != 0) + { + return FALSE; + } + else if (a->custom_palette != b->custom_palette) + { + return FALSE; + } + + return TRUE; +} + /** * cairo_font_options_create: * diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 0f4fd541a..8a253468d 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1748,7 +1748,7 @@ void _cairo_gstate_set_font_options (cairo_gstate_t *gstate, const cairo_font_options_t *options) { - if (memcmp (options, &gstate->font_options, sizeof (cairo_font_options_t)) == 0) + if (_cairo_font_options_compare (options, &gstate->font_options)) return; _cairo_gstate_unset_scaled_font (gstate); diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 91ee0e90b..78c7dd5ec 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -1471,10 +1471,14 @@ find_name (tt_name_t *name, unsigned long size, int name_id, int platform, int e if (offset + len > size) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - str = _cairo_strndup (((char*)name) + offset, len); + str = _cairo_malloc (len + 1); if (str == NULL) return _cairo_error (CAIRO_STATUS_NO_MEMORY); + memcpy (str, + ((char*)name) + offset, + len); + str[len] = 0; break; } } diff --git a/src/cairoint.h b/src/cairoint.h index 5ce747ee4..6682e4b30 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -897,6 +897,10 @@ cairo_private void _cairo_font_options_init_copy (cairo_font_options_t *options, const cairo_font_options_t *other); +cairo_private cairo_bool_t +_cairo_font_options_compare (const cairo_font_options_t *a, + const cairo_font_options_t *b); + cairo_private void _cairo_font_options_fini (cairo_font_options_t *options); diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp index 994889e21..edd606abe 100644 --- a/src/win32/cairo-dwrite-font.cpp +++ b/src/win32/cairo-dwrite-font.cpp @@ -1126,42 +1126,6 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s return CAIRO_INT_STATUS_SUCCESS; } -/* Helper function adapted from _compute_mask in cairo-win32-font.c */ - -/* Compute an alpha-mask from a monochrome RGB24 image - */ -static cairo_surface_t * -_compute_a8_mask (cairo_surface_t *surface) -{ - cairo_image_surface_t *glyph; - cairo_image_surface_t *mask; - int i, j; - - glyph = (cairo_image_surface_t *)cairo_surface_map_to_image (surface, NULL); - if (unlikely (glyph->base.status)) - return &glyph->base; - - /* No quality param, just use the non-ClearType path */ - - /* Compute an alpha-mask by using the green channel of a (presumed monochrome) - * RGB24 image. - */ - mask = (cairo_image_surface_t *) - cairo_image_surface_create (CAIRO_FORMAT_A8, glyph->width, glyph->height); - if (likely (mask->base.status == CAIRO_STATUS_SUCCESS)) { - for (i = 0; i < glyph->height; i++) { - uint32_t *p = (uint32_t *) (glyph->data + i * glyph->stride); - uint8_t *q = (uint8_t *) (mask->data + i * mask->stride); - - for (j = 0; j < glyph->width; j++) - *q++ = 255 - ((*p++ & 0x0000ff00) >> 8); - } - } - - cairo_surface_unmap_image (surface, &glyph->base); - return &mask->base; -} - static cairo_int_status_t _cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_font, cairo_scaled_glyph_t *scaled_glyph) @@ -1240,7 +1204,7 @@ _cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_ GdiFlush(); - image = _compute_a8_mask (&surface->base); + image = _cairo_compute_glyph_mask (&surface->base, CLEARTYPE_QUALITY); status = (cairo_int_status_t)image->status; if (status) goto FAIL; diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c index 6bc8bef94..fd9461363 100644 --- a/src/win32/cairo-win32-font.c +++ b/src/win32/cairo-win32-font.c @@ -1335,9 +1335,9 @@ _cairo_win32_scaled_font_load_type1_data (void *abstract_font, length); } -static cairo_surface_t * -_compute_mask (cairo_surface_t *surface, - int quality) +cairo_surface_t * +_cairo_compute_glyph_mask (cairo_surface_t *surface, + int quality) { cairo_image_surface_t *glyph; cairo_image_surface_t *mask; @@ -1421,7 +1421,7 @@ _cairo_win32_scaled_font_init_glyph_surface (cairo_win32_scaled_font_t *scaled_f if (status) goto FAIL; - image = _compute_mask (surface, scaled_font->quality); + image = _cairo_compute_glyph_mask (surface, scaled_font->quality); status = image->status; if (status) goto FAIL; diff --git a/src/win32/cairo-win32-private.h b/src/win32/cairo-win32-private.h index 486b12811..6af09c0e1 100644 --- a/src/win32/cairo-win32-private.h +++ b/src/win32/cairo-win32-private.h @@ -214,6 +214,10 @@ cairo_bool_t _cairo_win32_surface_get_extents (void *abstract_surface, cairo_rectangle_int_t *rectangle); +cairo_surface_t * +_cairo_compute_glyph_mask (cairo_surface_t *surface, + int quality); + uint32_t _cairo_win32_flags_for_dc (HDC dc, cairo_format_t format); |