From 956ccb11a8e29289302ff85f76713ceb31cfecc7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 31 Dec 2022 10:14:37 -0500 Subject: [PATCH] [docs] Add a section about rendering --- docs/usermanual-fonts-and-faces.xml | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/usermanual-fonts-and-faces.xml b/docs/usermanual-fonts-and-faces.xml index 72230b829..25fcaf47e 100644 --- a/docs/usermanual-fonts-and-faces.xml +++ b/docs/usermanual-fonts-and-faces.xml @@ -473,4 +473,46 @@ +
+ 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_glyph() + and pass a hb_paint_funcs_t struct with callbacks to obtain paint + graphs for glyphs that have them. The hb_font_paint_glyph() + API can handle outline and image glyphs as well, so it provides a unified API for + access to glyph rendering information. + +
+