Skip to content
Experimental text shaping in LuaTeX using Harfbuzz library
Lua TeX Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

LuaTeX Harfbuzz shaper

You need to install Luaharfbuzz first. It is best to use luarocks option, as we can load it directly.

Run make install to set correct paths in which luaharfbuzz will be searched. The library will be installed in yout local TEXMF tree.


This is just a proof of concept of using Harfbuzz library with LuaLaTeX. Context and Luaotfload tries to do glyph shaping with Lua functions, but it is lot of really hard work and complex scripts such as Arabic doesn't seem to be supported fully.




\font\libertine={Linux Libertine O} at 12pt
Normal text with Libertine: finance, grafika, 2015, 1/2


Zero: 2015

Oldstyle: 2015

Fractions: 1/2, 1/4


Hello world in small caps

\font\italic={Linux Libertine O/I} at 12pt

\italic Text in italic font

\font\arabic={amiri:script=arab;language=ara} at 12pt

Arabic text

{\pardir TRT \textdir TRT
\arabic مقالة اليوم المختارة}

Kerning and features: VLTAVA finance

\stopharfbuzz Without shaping: VLTAVA finance


Resulting document

LaTeX font selection commands

You can define font families which can be used in standard LaTeX commands such as \textit, \textbf or \textsc. The commands are:

\MainFamily[font options]{font name}
\SansFamily[font options]{font name}
\MonoFamily[font options]{font name}


\MainFamily[script=latn;+onum;]{TeX Gyre Termes}

Ligatures: finance 12345 \textit{diacritics: příliš} {\itshape font switch} 
\textsc{Small caps} \textit{\textbf{bold italic} italic} \texttt{monospace}

  for k,v in ipairs(t) do print(k,v) end

\[ \frac{\sqrt{a^2 +b ^ 2}}{c^2} \]


Fonts are loaded using Luaotfload libraries, which means that you can use fonts in both your system font directories and in TeX tree. Also, Luatfload syntax \font\fontname= {System font name/Style:features} at size is supported. Classical tfm and vf fonts are supported, but without any text shaping, obviously. To enable text shaping, use \startharfbuzz, to stop it, use \stopharfbuzz. Shaping is enabled by default.

You can set harfbuzz options with \SetFontOption, most useful options are features, script and language. All values must be valid OpenType names.

See files in examples directory for various examples of usage.

Questions and issues

  • Hyphenation works, except for ligatures. We need to investigate how to detect ligatures and how to create discretionaries needed by LuaTeX in order to enable hyphenation
  • kerning seems to work
  • complex scripts such as Arabic seems to work, even Urdu
  • how to handle font expansion and protrusion?


% Copyright 2015 Michal Hoftich

This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version. The latest version of this license is in and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Michal Hoftich

You can’t perform that action at this time.