mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-24 12:30:10 +01:00
Merge branch 'prefer-colrv1-table' into 'master'
Prefer COLRv1 table See merge request cairo/cairo!537
This commit is contained in:
commit
c604890473
2 changed files with 38 additions and 17 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue