[lltx] Patching fonts with the luaotfload callback "luaotfload.patch_font"

Khaled Hosny khaledhosny at eglug.org
Sun Feb 20 17:48:52 CET 2011

On Sat, Feb 05, 2011 at 03:28:14PM +0100, Ulrike Fischer wrote:
> I'm really happy that the newest version of luaotfload offers a
> callback "luaotfload.patch_font" which can be use to change fonts. I
> think that is really useful. As a first step I would like to use it
> to reencode some chess fonts so that they can be used with latex.
> Below is a small example of my first tests. It tries to replace the
> "a" by a "b". For all fonts in the example I get the expected "look"
> in the pdf ("bbc").

Another way to patch the fonts is to do something like:

\input luaotfload.sty
 local function chess(tfmdata,value)
     if value then
     % whatever
 fonts.initializers.base.otf.chess = chess
 fonts.initializers.node.otf.chess = chess
\font\test=name:foo:chess=yes at 15pt
\test foo

This way you can control which fonts to be processed, and "chess" option
can take any value so your code might even do different patching
conditionally (this should work for ConTeXt as well).

BTW, you can save "tfmdata" to a file using:
  table.tofile("file.lua", tfmdata, true)

If you want to inspect its structure.


 Khaled Hosny

More information about the lualatex-dev mailing list