[HarfBuzz] Features, masks and glyph attribution.

Khaled Hosny khaledhosny at eglug.org
Wed Feb 6 07:19:45 PST 2013


On Mon, Jan 28, 2013 at 10:42:02PM +0300, Alexander Sabourenkov wrote:
> Hello.
> 
> I'm stuck in understanding more general aspects of HarfBuzz and
> shaping; reading and tracing the code went into diminishing returns
> mode.
> 
> The task I'm struggling with is - after calling hb_shape(), map each
> resulting glyph to the unicode code point  in the initial string that
> caused the glyph in question to be emitted.

This is what “cluster” field of hb_glyph_info_t is for, they map to
input characters in the logical order. Here are some examples:

$ hb-shape amiri-regular.ttf --no-positions 'fni'
[f=0|n=1|i=2]

There are three input characters and three output glyphs with one two
one mapping.

$ hb-shape amiri-regular.ttf --no-positions 'fin'
[f_i=0|n=2]

There are three input characters and two glyphs only, missing clusters
are for glyphs “absorbed” in the ligature.

$ hb-shape amiri-regular.ttf --no-positions 'لگ'
[uni06AF.fina=1|uni0640.1=0|uni0644.init=0]

There are two input characters and three output glyphs, two of them has
the same cluster value because they belong to the same character, note
that the glyph order is reversed but cluster values match the logical
order of the input string.

You may also want to check how Pango utilizes this stuff.

Regards,
Khaled



More information about the HarfBuzz mailing list