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

Eli Zaretskii eliz at gnu.org
Sat May 25 16:22:49 UTC 2019


> Date: Sat, 25 May 2019 17:17:23 +0200
> From: Khaled Hosny <dr.khaled.hosny at gmail.com>
> Cc: Richard Wordingham <richard.wordingham at ntlworld.com>,
> 	harfbuzz at lists.freedesktop.org
> 
> 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.

Ah, okay.  Well, as you know, Emacs currently doesn't know the script
of a character at all, and only knows the global session-wide value of
the language, not the language of the text from which the character
came.  So in practice it seems the nominal glyph will do for now.

> 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).

Thanks, I will look into this later.  Right now I have a more urgent
issues: the glyph metrics seem to be wrong (width too large or
somesuch, not sure yet).

In general, though, Emacs never lays out entire paragraphs of text, I
think we pass at most a single screen line to the shaper.  Changing
that would probably need a significant redesign of the display code.


More information about the HarfBuzz mailing list