summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build7
-rw-r--r--src/cairo-font-options.c35
-rw-r--r--src/cairo-ft-font.c53
-rw-r--r--src/cairo-gstate.c2
-rw-r--r--src/cairo-truetype-subset.c6
-rw-r--r--src/cairoint.h4
6 files changed, 61 insertions, 46 deletions
diff --git a/meson.build b/meson.build
index 12512d115..5b6f9ebd5 100644
--- a/meson.build
+++ b/meson.build
@@ -4,8 +4,8 @@ project('cairo', 'c', 'cpp',
default_options: ['warning_level=2'],
)
-# Keep in sync with configure.ac!
freetype_required_version = '>= 9.7.3'
+freetype_colrv1_required_version = '>= 25.0.19'
fontconfig_required_version = '>= 2.2.95'
xrender_required_version = '>= 0.6'
xcb_required_version = '>= 1.6'
@@ -342,9 +342,8 @@ if freetype_dep.found()
conf.set('CAIRO_CAN_TEST_TTX_FONT', 1)
endif
endif
- # When FT COLRv1 API is no longer experimental we can change this to a
- # version check for the stable COLRv1 API.
- if cc.get_define('DEBUG_ENABLE_COLR_V1') != ''
+ if freetype_dep.version().version_compare(freetype_colrv1_required_version) and \
+ cc.has_function('FT_Get_Color_Glyph_Paint', dependencies: freetype_dep)
conf.set('HAVE_FT_COLR_V1', 1)
endif
check_funcs += ft_check_funcs
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-ft-font.c b/src/cairo-ft-font.c
index 75d6f8c16..22a6a622b 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -3408,7 +3408,6 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
int load_flags = scaled_font->ft_options.load_flags;
cairo_bool_t vertical_layout = FALSE;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- cairo_bool_t scaled_glyph_loaded = FALSE;
cairo_ft_glyph_private_t *glyph_priv;
int color_flag = 0;
@@ -3528,46 +3527,20 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
if (info & CAIRO_SCALED_GLYPH_INFO_PATH) {
cairo_path_fixed_t *path = NULL; /* hide compiler warning */
- if (scaled_glyph->has_info & CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE) {
- path = _cairo_path_fixed_create ();
- if (!path) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- goto FAIL;
- }
-
- status = _cairo_recording_surface_get_path (scaled_glyph->recording_surface, path);
- if (unlikely (status)) {
- _cairo_path_fixed_destroy (path);
- goto FAIL;
- }
-
- } else {
- /*
- * A kludge -- the above code will trash the outline,
- * so reload it. This will probably never occur though
- */
- if ((info & (CAIRO_SCALED_GLYPH_INFO_SURFACE | CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE)) != 0) {
- scaled_glyph_loaded = FALSE;
- load_flags |= FT_LOAD_NO_BITMAP;
- }
-
- if (!scaled_glyph_loaded) {
- status = _cairo_ft_scaled_glyph_load_glyph (scaled_font,
- scaled_glyph,
- face,
- load_flags,
- FALSE,
- vertical_layout);
- if (unlikely (status))
- goto FAIL;
- }
+ /* Load non-color glyph */
+ status = _cairo_ft_scaled_glyph_load_glyph (scaled_font,
+ scaled_glyph,
+ face,
+ load_flags,
+ FALSE,
+ vertical_layout);
+ if (unlikely (status))
+ goto FAIL;
- if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
- status = _cairo_ft_face_decompose_glyph_outline (face, &path);
- } else {
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- }
- }
+ if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
+ status = _cairo_ft_face_decompose_glyph_outline (face, &path);
+ else
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
if (unlikely (status))
goto FAIL;
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);