[HarfBuzz] Some beginner questions about using Harfbuzz API

Deepak Jois deepak.jois at gmail.com
Mon Nov 30 09:33:52 PST 2015


I am trying to build a Lua interface to Harfbuzz that I can hopefully
use with LuaTeX some day. I have got something working after taking
inspiration from the harfbuzz-tutorial code[2], and the Lua
bindings[3] in Simon Cozen’s SILE package. What I have works for the
basic cases, but I had a few questions about some API functions that I
wanted to clarify here.

For reference, here[1] is the code I am referring to. My questions are:

* Why are there two different ways to create font-like objects? There
is hb_face_create/hb_font_create (used in SILE) and hb_ft_font_create
(used in harfbuzz-tutorial). Any guidelienes on what one should use?

* Are there any helper methods to create font blobs from files?
Currently the code just slurps the file contents (in Lua) and then
passes it on as a char * to the C code.

* I don’t fully understand the concept of font indexes. I guess it’s
something meant to disambiguate fonts in font-collections. However,
what about the case when a single file contains a single font? I am
using 0 as the font-index for those cases. Is that fine?

* What does the call hb_ot_font_set_funcs(hb_font) do?

* I suppose the way to get glyph names is to use
hb_font_get_glyph_name(…). However that does not work in my code,
although hb-shape seems to report the glyph names correctly. All I get
are empty strings. Any clues as to what I might be doing wrong.

*  Why does the harfbuzz-tutorial code divide the values by 64 before
printing it out or sending it to the Cairo drawing API. I am guessing
it has something to do with DPI values of output display devices but I
don’t fully understand it. Is that an arbitrary choice, or the most
commonly used value?

Thanks
Deepak

[1]: https://github.com/deepakjois/luatex-harfbuzz-shaper/blob/master/luaharfbuzz.c#L19

[2]: https://github.com/behdad/harfbuzz-tutorial

[3]: https://github.com/simoncozens/sile/blob/master/src/justenoughharfbuzz.c


More information about the HarfBuzz mailing list