Skip to content

Add color palette font option

Adrian Johnson requested to merge ajohnson/cairo:palette-option into master

One of the things I found I needed while implementing !319 (merged) is a way to select the CPAL color palette. It is also required in the DirectWrite backend where the color palette index is a parameter to the TranslateColorGlyphRun() and DrawSvgGlyphRun() functions. FreeType also provides a function to set the palette index.

The API I created is

#define CAIRO_COLOR_PALETTE_DEFAULT 0

cairo_public int
cairo_font_options_get_color_palette (cairo_font_options_t *options);

cairo_public void
cairo_font_options_set_color_palette (cairo_font_options_t *options,
                                      int                   palette_index);

The CPAL table provides a display name for each palette so it would be up to the application to present the names to user and convert it to an index.

Merge request reports