[luatex] Experimental Harfbuzz package

Michal Hoftich michal.h21 at gmail.com
Wed May 13 17:49:11 CEST 2015

Hi all,

I've tried to use Lua bindings for Harfbuzz text shaper, provided by
Sile [1], with LuaLaTeX. The Sile Harfbuzz bindings library provides
two functions, one loads a font to Harfbuzz, the second does actual
text shaping with selected font.

I used sample font loader from LuaTeX wiki [2] as the base. It seems
to work for both OpenType and classical TeX fonts, with little
modification. For OpenType fonts,  immediately following glyph nodes
with the same font, language and attributes are collected in
pre_linebreak_filter callback, the text is processed with Harfbuzz,
table with characters is returned, new glyphs with properties of old
nodes are created and the old nodes are replaced with the new ones.
All node types other than glyph are leaved in the node list as they

This means that only separate parts of a word may be shaped, when it
contains whatsit node for example, which may result in missing
ligature or other features sometimes. Also, because only a word is
processed at any moment, this may not suffice for complex scripts like
Arabic, where it is important where line start ending play role in the
shaping (if I understand it correctly). In particular, my Arabic tests
seems to be OK with some fonts, but they seems to fail with Khaled
Hosny's Amiri for some reason.

The package for LuaLaTeX is located on Github [3], some sample files
show  Latin, Devanagari, Cyrillic and Greek scripts [4]. Note that
hyphenation of Greek and Russian seems to work using Babel. The other
example shows various Asian and Arabic scripts: [5].

The package is highly experimental and I am sure it has many
shortcomings, I listed some issues in the README, but at least it is a
proof of concept that Harfbuzz can be used with LuaTeX.

Best regards,

[1] https://github.com/simoncozens/sile
[2] http://wiki.luatex.org/index.php/Use_a_TrueType_font
[3] https://github.com/michal-h21/luatex-harfbuzz-shaper
[4] https://github.com/michal-h21/luatex-harfbuzz-shaper/blob/master/examples/ahoj.pdf
[5] https://github.com/michal-h21/luatex-harfbuzz-shaper/blob/master/examples/scripts.pdf

More information about the luatex mailing list