summaryrefslogtreecommitdiff
path: root/pango/pangocairo-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-02-13 13:19:45 -0600
committerMatthias Clasen <mclasen@redhat.com>2022-02-13 13:19:45 -0600
commitd4cf0b1c8dcdef31644879d6fbae11002828b927 (patch)
treecdf42ee36f3f1802aa6dbcd104633d8af94607da /pango/pangocairo-font.c
parent9cb392f306e96534337b177eeee4e1239e8ab337 (diff)
downloadpango-font-palette-api.tar.gz
wip: Add an api to select palettes for color glyphsfont-palette-api
This commit adds a light-background attribute that can be used to influence which palette will be used to render COLRv0 layered glyphs with color fonts that have multiple palettes. This needs a way for cairo to invalidate its glyph cache when the selected palette changes, which needs new freetype api.
Diffstat (limited to 'pango/pangocairo-font.c')
-rw-r--r--pango/pangocairo-font.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 598065c0..9d1fca2e 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -26,6 +26,7 @@
#include "pangocairo.h"
#include "pangocairo-private.h"
+#include "pangocairo-fc-private.h"
#include "pango-font-private.h"
#include "pango-impl-utils.h"
@@ -164,6 +165,7 @@ pango_cairo_font_get_scaled_font (PangoCairoFont *cfont)
/**
* _pango_cairo_font_install:
* @font: a `PangoCairoFont`
+ * @renderer: a `PangoCairoRenderer`
* @cr: a #cairo_t
*
* Makes @font the current font for rendering in the specified
@@ -173,18 +175,32 @@ pango_cairo_font_get_scaled_font (PangoCairoFont *cfont)
*/
gboolean
_pango_cairo_font_install (PangoFont *font,
- cairo_t *cr)
+ cairo_t *cr,
+ gboolean has_light_background)
{
cairo_scaled_font_t *scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)font);
if (G_UNLIKELY (scaled_font == NULL || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS))
return FALSE;
+ if (PANGO_IS_FC_FONT (font))
+ pango_cairo_fc_font_install (PANGO_FC_FONT (font), cr, has_light_background);
+
cairo_set_scaled_font (cr, scaled_font);
return TRUE;
}
+gboolean
+_pango_cairo_font_uninstall (PangoFont *font,
+ cairo_t *cr)
+{
+ if (PANGO_IS_FC_FONT (font))
+ pango_cairo_fc_font_uninstall (PANGO_FC_FONT (font), cr);
+
+ return TRUE;
+}
+
static int
max_glyph_width (PangoLayout *layout)