2 commits - meson.build src/cairo-ft-font.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Mar 21 20:55:21 UTC 2024
meson.build | 3 +++
src/cairo-ft-font.c | 52 +++++++++++++++++++++++++++++++++++-----------------
2 files changed, 38 insertions(+), 17 deletions(-)
New commits:
commit c60489047387d66e21d5318da26c30f77caad4e9
Merge: a269e6085 1bd4d5970
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Mar 21 20:55:15 2024 +0000
Merge branch 'prefer-colrv1-table' into 'master'
Prefer COLRv1 table
See merge request cairo/cairo!537
commit 1bd4d59705f29ad871e3194385ff1790434fce35
Author: Marek Kasik <mkasik at redhat.com>
Date: Thu Mar 21 20:55:15 2024 +0000
Prefer COLRv1 table
diff --git a/meson.build b/meson.build
index 9efe91978..fc334f64b 100644
--- a/meson.build
+++ b/meson.build
@@ -340,6 +340,9 @@ if freetype_dep.found()
conf.set('CAIRO_CAN_TEST_TTX_FONT', 1)
endif
endif
+ if cc.get_define('FT_LOAD_NO_SVG', dependencies: freetype_dep, prefix: '#include <freetype/freetype.h>') != ''
+ conf.set('HAVE_FT_LOAD_NO_SVG', 1)
+ endif
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)
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index bf0872e93..56a307d5a 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2435,6 +2435,22 @@ done:
}
}
+typedef enum {
+ CAIRO_FT_GLYPH_TYPE_BITMAP,
+ CAIRO_FT_GLYPH_TYPE_OUTLINE,
+ CAIRO_FT_GLYPH_TYPE_SVG,
+ CAIRO_FT_GLYPH_TYPE_COLR_V0,
+ CAIRO_FT_GLYPH_TYPE_COLR_V1,
+} cairo_ft_glyph_format_t;
+
+typedef struct {
+ cairo_scaled_glyph_private_t base;
+
+ cairo_ft_glyph_format_t format;
+} cairo_ft_glyph_private_t;
+
+static const int ft_glyph_private_key;
+
static cairo_int_status_t
_cairo_ft_scaled_glyph_load_glyph (cairo_ft_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph,
@@ -2445,6 +2461,11 @@ _cairo_ft_scaled_glyph_load_glyph (cairo_ft_scaled_font_t *scaled_font,
{
FT_Error error;
cairo_status_t status;
+ cairo_ft_glyph_private_t *glyph_priv;
+
+ glyph_priv = (cairo_ft_glyph_private_t *) _cairo_scaled_glyph_find_private (scaled_glyph,
+ &ft_glyph_private_key);
+ assert (glyph_priv != NULL);
if (use_em_size) {
cairo_matrix_t em_size;
@@ -2459,6 +2480,11 @@ _cairo_ft_scaled_glyph_load_glyph (cairo_ft_scaled_font_t *scaled_font,
cairo_ft_apply_variations (face, scaled_font);
+#if defined(FT_LOAD_COLOR) && defined(HAVE_FT_LOAD_NO_SVG)
+ if (load_flags & FT_LOAD_COLOR && glyph_priv->format == CAIRO_FT_GLYPH_TYPE_COLR_V1)
+ load_flags |= FT_LOAD_NO_SVG;
+#endif
+
error = FT_Load_Glyph (face,
_cairo_scaled_glyph_index(scaled_glyph),
load_flags);
@@ -2495,20 +2521,6 @@ _cairo_ft_scaled_glyph_load_glyph (cairo_ft_scaled_font_t *scaled_font,
return CAIRO_STATUS_SUCCESS;
}
-typedef enum {
- CAIRO_FT_GLYPH_TYPE_BITMAP,
- CAIRO_FT_GLYPH_TYPE_OUTLINE,
- CAIRO_FT_GLYPH_TYPE_SVG,
- CAIRO_FT_GLYPH_TYPE_COLR_V0,
- CAIRO_FT_GLYPH_TYPE_COLR_V1,
-} cairo_ft_glyph_format_t;
-
-typedef struct {
- cairo_scaled_glyph_private_t base;
-
- cairo_ft_glyph_format_t format;
-} cairo_ft_glyph_private_t;
-
static void
_cairo_ft_glyph_fini (cairo_scaled_glyph_private_t *glyph_private,
cairo_scaled_glyph_t *glyph,
@@ -3274,8 +3286,6 @@ _cairo_ft_scaled_glyph_is_colr_v1 (cairo_ft_scaled_font_t *scaled_font,
return FALSE;
}
-static const int ft_glyph_private_key;
-
static cairo_int_status_t
_cairo_ft_scaled_glyph_init_metrics (cairo_ft_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph,
@@ -3328,7 +3338,15 @@ _cairo_ft_scaled_glyph_init_metrics (cairo_ft_scaled_font_t *scaled_font,
#endif
if (is_svg_format) {
- glyph_priv->format = CAIRO_FT_GLYPH_TYPE_SVG;
+ glyph_priv->format = CAIRO_FT_GLYPH_TYPE_SVG;
+
+#if defined(HAVE_FT_COLR_V1) && defined(HAVE_FT_LOAD_NO_SVG)
+ /* Prefer COLRv1 table over SVG table due to performance reasons for now */
+ if (_cairo_ft_scaled_glyph_is_colr_v1 (scaled_font, scaled_glyph, face)) {
+ glyph_priv->format = CAIRO_FT_GLYPH_TYPE_COLR_V1;
+ }
+#endif
+
} else if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
glyph_priv->format = CAIRO_FT_GLYPH_TYPE_OUTLINE;
if (color_flag) {
More information about the cairo-commit
mailing list