[HarfBuzz] How to get a glyph code for a character?

Khaled Hosny dr.khaled.hosny at gmail.com
Sat May 25 15:17:23 UTC 2019


On Sat, May 25, 2019 at 06:08:42PM +0300, Eli Zaretskii wrote:
> > Date: Sat, 25 May 2019 15:50:38 +0100
> > From: Richard Wordingham <richard.wordingham at ntlworld.com>
> > 
> > I presume you're after the glyph indicated by the raw cmap, e.g.
> > without localisation.
> 
> Not sure what kind of localisation are you alluding to here.  I must
> confess that I'm relatively ignorant about fonts, glyphs, and shaping,
> so I'm probably missing a lot here.  For example, I have no idea what
> is a "raw cmap".

For any given script and language, the font might provide a different
localized glyph than the default one. Only hb_shape[_full]() will apply
such localization.

> > Using hb_shape could very well result in the addition of a dotted
> > circle for a combining mark - is that what you want?
> 
> AFAIK, this method is only called in Emacs for a combining mark when
> we indeed want it displayed as a separate character, with the dotted
> circle.  It is normally called for base (non-combining) characters.

Then hb_shape() is the right tool here. HarfBuzz will also automatically
insert dotted circle for combining marks that are at the start of the
text string if HB_BUFFER_FLAG_BOT is set on the buffer. You can safely
set HB_BUFFER_FLAG_BOT and HB_BUFFER_FLAG_EOT on any buffer as long as
the text passed to hb_buffer_add* functions is the full paragraph text
not just a chunk of it (that is another reason why one should pass the
full paragraph and the item offset and length to these function instead
of just the substring).

Regards,
Khaled


More information about the HarfBuzz mailing list