manpagez: man pages & more
html files: goocanvas
Home | html | info | man

Font objects and HarfBuzz's native OpenType implementation

By default, whenever HarfBuzz creates a font object, it will configure the font to use a built-in set of font functions that supports contemporary OpenType font internals. If you want to work with OpenType or TrueType fonts, you should be able to use these functions without difficulty.

Many of the methods in the font-functions structure deal with the fundamental properties of glyphs that are required for shaping text: extents (the maximums and minimums on each axis), origins (the (0,0) coordinate point which glyphs are drawn in reference to), and advances (the amount that the cursor needs to be moved after drawing each glyph, including any empty space for the glyph's side bearings).

As you can see in the list of functions, there are separate "horizontal" and "vertical" variants depending on whether the text is set in the horizontal or vertical direction. For some scripts, fonts that are designed to support text set horizontally or vertically (for example, in Japanese) may include metrics for both text directions. When fonts don't include this information, HarfBuzz does its best to transform what the font provides.

In addition to the direction-specific functions, HarfBuzz provides some higher-level functions for fetching information like extents and advances for a glyph. If you call

      hb_font_get_glyph_advance_for_direction(font, direction, extents);
    

then you can provide any hb_direction_t as the direction parameter, and HarfBuzz will use the correct function variant for the text direction. There are similar higher-level versions of the functions for fetching extents, origin coordinates, and contour-point coordinates. There are also addition and subtraction functions for moving points with respect to the origin.

There are also methods for fetching the glyph ID that corresponds to a Unicode code point (possibly when followed by a variation-selector code point), fetching the glyph name from the font, and fetching the glyph ID that corresponds to a glyph name you already have.

HarfBuzz also provides functions for converting between glyph names and string variables. hb_font_glyph_to_string(font, glyph, s, size) retrieves the name for the glyph ID glyph from the font object. It generates a generic name of the form gidDDD (where DDD is the glyph index) if there is no name for the glyph in the font. The hb_font_glyph_from_string(font, s, len, glyph) takes an input string s and looks for a glyph with that name in the font, returning its glyph ID in the glyph output parameter. It automatically parses gidDDD and uniUUUU strings.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.