Glyphs and rendering: HarfBuzz Manual

## Glyphs and rendering

The main purpose of HarfBuzz is shaping, which creates a list of positioned glyphs as output. The remaining task for text layout is to convert this list into rendered output. While HarfBuzz does not handle rasterization of glyphs per se, it does have APIs that provide access to the font data that is needed to perform this task.

Traditionally, the shapes of glyphs in scalable fonts are provided as quadratic or cubic Beziér curves defining outlines to be filled. To obtain the outlines for a glyph, call `hb_font_draw_glyph()` and pass a hb_draw_funcs_t struct. The callbacks in that struct will be called for each segment of the outline. Note that this API provides access to outlines as they are defined in the font, without applying hinting to fit the curves to the pixel grid.

Fonts may provide pre-rendered images for glyphs instead of or in addition to outlines. This is most common for fonts that contain colored glyphs, such as Emoji. To access these images, use `hb_ot_color_reference_png()` or `hb_ot_color_reference_svg()`.

Another way in which fonts provide colored glyphs is via paint graphs that combine glyph outlines with gradients and allow for transformations and compositing. In its simplest form, this can be presented as a series of layers that are rendered on top of each other, each with its own color. HarfBuzz has the `hb_ot_color_glyph_get_layers()` to access glyph data in this form.

In the general case, you have to use `hb_font_paint_or_fail_glyph()` and pass a hb_paint_funcs_t struct with callbacks to obtain paint color glyphs, either graphs or image glyphs. The `hb_font_paint_glyph()` API is higher level and can handle outline glyphs as well, so it provides a unified API for access to glyph rendering information.