diff --git a/cogl/cogl-pango/cogl-pango-display-list.c b/cogl/cogl-pango/cogl-pango-display-list.c index 8615402b9..e4bb1275d 100644 --- a/cogl/cogl-pango/cogl-pango-display-list.c +++ b/cogl/cogl-pango/cogl-pango-display-list.c @@ -81,6 +81,7 @@ struct _CoglPangoDisplayListNode GArray *rectangles; /* A primitive representing those vertices */ CoglPrimitive *primitive; + guint has_color : 1; } texture; struct diff --git a/cogl/cogl-pango/cogl-pango-glyph-cache.h b/cogl/cogl-pango/cogl-pango-glyph-cache.h index ec0616acc..0e523184d 100644 --- a/cogl/cogl-pango/cogl-pango-glyph-cache.h +++ b/cogl/cogl-pango/cogl-pango-glyph-cache.h @@ -58,7 +58,9 @@ struct _CoglPangoGlyphCacheValue /* This will be set to TRUE when the glyph atlas is reorganized which means the glyph will need to be redrawn */ - gboolean dirty; + guint dirty : 1; + /* Set to TRUE if the glyph has colors (eg. emoji) */ + guint has_color : 1; }; typedef void (* CoglPangoGlyphCacheDirtyFunc) (PangoFont *font, diff --git a/cogl/cogl-pango/cogl-pango-render.c b/cogl/cogl-pango/cogl-pango-render.c index dedc0433f..d1ef39cb0 100644 --- a/cogl/cogl-pango/cogl-pango-render.c +++ b/cogl/cogl-pango/cogl-pango-render.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "cogl/cogl-debug.h" #include "cogl/cogl-context-private.h" @@ -526,6 +527,24 @@ cogl_pango_renderer_get_cached_glyph (PangoRenderer *renderer, create, font, glyph); } +static gboolean +font_has_color_glyphs (const PangoFont *font) +{ + cairo_scaled_font_t *scaled_font; + gboolean has_color = FALSE; + + scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *) font); + + if (cairo_scaled_font_get_type (scaled_font) == CAIRO_FONT_TYPE_FT) + { + FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); + has_color = (FT_HAS_COLOR (ft_face) != 0); + cairo_ft_scaled_font_unlock_face (scaled_font); + } + + return has_color; +} + static void cogl_pango_renderer_set_dirty_glyph (PangoFont *font, PangoGlyph glyph, @@ -600,6 +619,8 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font, cairo_image_surface_get_data (surface)); cairo_surface_destroy (surface); + + value->has_color = font_has_color_glyphs (font); } static void