## hb-ot-color

hb-ot-color — OpenType Color Fonts

## Functions

#define | HB_COLOR()
#define | hb_color_get_alpha()
#define | hb_color_get_blue()
#define | hb_color_get_green()
#define | hb_color_get_red()
unsigned int | hb_ot_color_glyph_get_layers ()
hb_blob_t * | hb_ot_color_glyph_reference_png ()
hb_blob_t * | hb_ot_color_glyph_reference_svg ()
hb_bool_t | hb_ot_color_has_layers ()
hb_bool_t | hb_ot_color_has_palettes ()
hb_bool_t | hb_ot_color_has_png ()
hb_bool_t | hb_ot_color_has_svg ()
hb_ot_name_id_t | hb_ot_color_palette_color_get_name_id ()
unsigned int | hb_ot_color_palette_get_colors ()
unsigned int | hb_ot_color_palette_get_count ()
hb_ot_color_palette_flags_t | hb_ot_color_palette_get_flags ()
hb_ot_name_id_t | hb_ot_color_palette_get_name_id ()

## Types and Values

typedef | hb_color_t
enum | hb_ot_color_palette_flags_t

## Includes

    #include <hb-ot.h>

## Description

Functions for fetching color-font information from OpenType font faces.

## Functions

### HB_COLOR()

    #define HB_COLOR(b,g,r,a) ((hb_color_t) HB_TAG ((b),(g),(r),(a)))

### hb_color_get_alpha()

    #define hb_color_get_alpha(color) ((color) & 0xFF)

Since: 2.1.0

### hb_color_get_blue()

    #define hb_color_get_blue(color) (((color) >> 24) & 0xFF)

Since: 2.1.0

### hb_color_get_green()

    #define hb_color_get_green(color) (((color) >> 16) & 0xFF)

Since: 2.1.0

### hb_color_get_red()

    #define hb_color_get_red(color)		(((color) >> 8) & 0xFF)

Since: 2.1.0

### hb_ot_color_glyph_get_layers ()

    unsigned int
    hb_ot_color_glyph_get_layers (hb_face_t *face,
                                  hb_codepoint_t glyph,
                                  unsigned int start_offset,
                                  unsigned int *count,
                                  hb_ot_color_layer_t *layers);

#### Parameters

face | a font face. |
glyph | a layered color glyph id. |
start_offset | starting offset of layers. |
count | gets number of layers available to be written on buffer and returns number of written layers. | [inout][optional]
layers | layers buffer to buffer. | [array length=count][out][optional]

#### Returns

Total number of layers a layered color glyph have.

Since: 2.1.0

### hb_ot_color_glyph_reference_png ()

    hb_blob_t *
    hb_ot_color_glyph_reference_png (hb_font_t *font,
                                     hb_codepoint_t glyph);

Get PNG image for a glyph.

#### Parameters

font | a font object, not face. upem should be set on that font object if one wants to get optimal png blob, otherwise return the biggest one |
glyph | a glyph index. |

#### Returns

respective PNG blob of the glyph, if available.

[transfer full]

Since: 2.1.0

### hb_ot_color_glyph_reference_svg ()

    hb_blob_t *
    hb_ot_color_glyph_reference_svg (hb_face_t *face,
                                     hb_codepoint_t glyph);

Get SVG document for a glyph. The blob may be either plain text or gzip-encoded.

#### Parameters

face | a font face. |
glyph | a svg glyph index. |

#### Returns

respective svg blob of the glyph, if available.

[transfer full]

Since: 2.1.0

### hb_ot_color_has_layers ()

    hb_bool_t
    hb_ot_color_has_layers (hb_face_t *face);

#### Parameters

face | a font face. |

#### Returns

whether COLR table is available.

Since: 2.1.0

### hb_ot_color_has_palettes ()

    hb_bool_t
    hb_ot_color_has_palettes (hb_face_t *face);

#### Parameters

face | a font face. |

#### Returns

whether CPAL table is available.

Since: 2.1.0

### hb_ot_color_has_png ()

    hb_bool_t
    hb_ot_color_has_png (hb_face_t *face);

Check whether `face` has PNG glyph images (either CBDT or sbix tables).

Returns true if available, false otherwise.

#### Parameters

face | a font face. |

Since: 2.1.0

### hb_ot_color_has_svg ()

    hb_bool_t
    hb_ot_color_has_svg (hb_face_t *face);

Check whether `face` has SVG glyph images.

Returns true if available, false otherwise.

#### Parameters

face | a font face. |

Since: 2.1.0

### hb_ot_color_palette_color_get_name_id ()

    hb_ot_name_id_t
    hb_ot_color_palette_color_get_name_id (hb_face_t *face,
                                           unsigned int color_index);

#### Parameters

face | a font face. |
color_index | palette entry index. |

#### Returns

Name ID associated with a palette entry, e.g. eye color

Since: 2.1.0

### hb_ot_color_palette_get_colors ()

    unsigned int
    hb_ot_color_palette_get_colors (hb_face_t *face,
                                    unsigned int palette_index,
                                    unsigned int start_offset,
                                    unsigned int *color_count,
                                    hb_color_t *colors);

Retrieves the colors in a color palette.

#### Parameters

face | a font face. |
palette_index | the index of the color palette whose colors are being requested. |
start_offset | the index of the first color being requested. |
color_count | on input, how many colors can be maximally stored into the `colors` array; on output, how many colors were actually stored. | [inout][optional]
colors | an array of hb_color_t records. After calling this function, `colors` will be filled with the palette colors. If `colors` is NULL, the function will just return the number of total colors without storing any actual colors; this can be used for allocating a buffer of suitable size before calling `hb_ot_color_palette_get_colors()` a second time. | [array length=color_count][out][optional]

#### Returns

the total number of colors in the palette.

Since: 2.1.0

### hb_ot_color_palette_get_count ()

    unsigned int
    hb_ot_color_palette_get_count (hb_face_t *face);

#### Parameters

face | a font face. |

#### Returns

the number of color palettes in `face` , or zero if `face` has no colors.

Since: 2.1.0

### hb_ot_color_palette_get_flags ()

    hb_ot_color_palette_flags_t
    hb_ot_color_palette_get_flags (hb_face_t *face,
                                   unsigned int palette_index);

#### Parameters

face | a font face |
palette_index | the index of the color palette whose flags are being requested |

#### Returns

the flags for the requested color palette.

Since: 2.1.0

### hb_ot_color_palette_get_name_id ()

    hb_ot_name_id_t
    hb_ot_color_palette_get_name_id (hb_face_t *face,
                                     unsigned int palette_index);

Retrieves the name id of a color palette. For example, a color font can have themed palettes like "Spring", "Summer", "Fall", and "Winter".

#### Parameters

face | a font face. |
palette_index | the index of the color palette whose name is being requested. |

#### Returns

an identifier within `face` 's `name` table. If the requested palette has no name the result is HB_OT_NAME_ID_INVALID.

Since: 2.1.0

## Types and Values

### hb_color_t

    typedef uint32_t hb_color_t;

Data type for holding color values.

Since: 2.1.0

### enum hb_ot_color_palette_flags_t

#### Members

HB_OT_COLOR_PALETTE_FLAG_DEFAULT | default indicating that there is nothing special to note about a color palette. |
HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND | flag indicating that the color palette is appropriate to use when displaying the font on a light background such as white. |
HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND | flag indicating that the color palette is appropriate to use when displaying the font on a dark background such as black. |

Since: 2.1.0