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

Ulrike Fischer news3 at nililand.de
Sun Feb 6 18:03:46 CET 2011

Am Sat, 5 Feb 2011 21:31:46 +0100 schrieb Philipp Stephani:

>> 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").
>> I have two questions:
>> 1. I added some messages to the function (for diagnosing), but they
>> don't appear for all fonts in the log/terminal. I see messages from
>> the fontspec-fonts "The font is \EU2/lmr/m/it/10" but not from
>> "\font\mytest" and "\font\mytestb". The curious thing is that I get
>> a "The font is \mytest"-message if I uncomment the last fontspec, I
>> can't find a rule, why some messages appear and other not. Has
>> someone an idea?
> Font loading happens *before* the font is assigned to a font
> definition token, and before selecting the font.

Yes I realized that some time I sent the question. Pitty as I wanted
to use the information about the TeX-fontname in the patch.  

> I think for your problem you should prefer virtual fonts over font
> patching. I requested the addition of the patch_font callback to
> be able to fix minor bugs (e.g. a wrong math parameter in Cambria
> Math) during font loading. Remapping characters should probably
> be done by means of virtual fonts:

In theory I agree, after my first tests I didn't feel very
confortable with the patch_callback as if affects every font. In
practice I don't know how to use virtual fonts in sensible way. In
your example you are activitating the virtual fonts with some
luacode (\luadirect{select_virtual_font()}) and you have to load the
real font before. 

But I want in the end to do something like
\font\myfont="myvirtualfont". The luatex manual contains an example
with a virtual font and this syntax. But it uses the define_callback
to implement it and at my opinion this is not the right place to
define a single virtual font. It would be much better if one could
store the definitions of the virtual font in a stand-alone file and
let luaotfload "find" and handle the font. But I don't neither if
this is already possible nor how. 

Ulrike Fischer 

More information about the lualatex-dev mailing list