1 +ˆl–ßi~””†»Ò�vàp©‹FÿÁ ƒl 3_‡I|¥‰ÓMÁÀ³ Getting started with HarfBuzz: HarfBuzz Manual

Getting started with HarfBuzz

An overview of the HarfBuzz shaping API
Terminology
A simple shaping example

An overview of the HarfBuzz shaping API

The core of the HarfBuzz shaping API is the function hb_shape(). This function takes a font, a buffer containing a string of Unicode codepoints and (optionally) a list of font features as its input. It replaces the codepoints in the buffer with the corresponding glyphs from the font, correctly ordered and positioned, and with any of the optional font features applied.

In addition to holding the pre-shaping input (the Unicode codepoints that comprise the input string) and the post-shaping output (the glyphs and positions), a HarfBuzz buffer has several properties that affect shaping. The most important are the text-flow direction (e.g., left-to-right, right-to-left, top-to-bottom, or bottom-to-top), the script tag, and the language tag.

For input string buffers, flags are available to denote when the buffer represents the beginning or end of a paragraph, to indicate whether or not to visibly render Unicode Default Ignorable codepoints, and to modify the cluster-merging behavior for the buffer. For shaped output buffers, the individual X and Y offsets and advances (the logical dimensions) of each glyph are accessible. HarfBuzz also flags glyphs as UNSAFE_TO_BREAK if breaking the string at that glyph (e.g., in a line-breaking or hyphenation process) would require re-shaping the text.

HarfBuzz also provides methods to compare the contents of buffers, join buffers, normalize buffer contents, and handle invalid codepoints, as well as to determine the state of a buffer (e.g., input codepoints or output glyphs). Buffer lifecycles are managed and all buffers are reference-counted.

Although the de