[lltx] Patching fonts with the luaotfload callback "luaotfload.patch_font"
Ulrike Fischer
news3 at nililand.de
Mon Feb 21 17:04:39 CET 2011
Am Sun, 20 Feb 2011 18:48:52 +0200 schrieb Khaled Hosny:
> Another way to patch the fonts is to do something like:
>
> \input luaotfload.sty
> \directlua{
> local function chess(tfmdata,value)
> if value then
> % whatever
> end
> end
> table.insert(fonts.triggers,"chess")
> fonts.initializers.base.otf.chess = chess
> fonts.initializers.node.otf.chess = chess
> }
> \font\test=name:foo:chess=yes at 15pt
> \test foo
> \bye
>
> 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).
This seems to work great. I even can declare the font in the normal
latex way:
\documentclass{article}
\usepackage[LSF,T1]{fontenc}
\DeclareFontFamily{LSF}{skaknewOTF}{}
\DeclareFontShape{LSF}{skaknewOTF}{m}{n}{<->
file:SkakNew-Figurine.otf:chess=yes}{}
\usepackage{luaotfload}
\directlua{
local function chess(tfmdata,value)
if value then
tfmdata.indices[75]=14
table.tofile("filechess.lua", tfmdata, true)
end
end
table.insert(fonts.triggers,"chess")
fonts.initializers.base.otf.chess = chess
fonts.initializers.node.otf.chess = chess
}
\begin{document}
\fontfamily{skaknewOTF}\fontencoding{LSF}\selectfont KQ
\end{document}
> BTW, you can save "tfmdata" to a file using:
> table.tofile("file.lua", tfmdata, true)
>
> If you want to inspect its structure.
Well here starts the problems. I can see the structure, but how can
I understand it? Which tables and table entries do I have to copy to
get a clean reencoding? Above I set the "indices" to copy the queen
to the "K" (which normally shows a king in this font). But I doubt
that the bounding box and other things are correct.
Also the tfmdata seems to contain a lot of data more than once. E.g.
"indices" exist also in the luatex table.
--
Ulrike Fischer
More information about the lualatex-dev
mailing list