[luatex] How to access user-defined kerning
Henri Menke
henrimenke at gmail.com
Fri Apr 20 08:24:09 CEST 2018
On Fri, 2018-04-20 at 07:47 +0200, Herbert Voss wrote:
> Am 20.04.2018 um 05:52 schrieb Henri Menke:
>
> >
> > I'm trying to determine the kerning between two letters (here A and V). For
> > the
> > sake of this example I'm inserting negative kerning of -400/1000 em.
> > However,
> > when I examine the kern in the kerning callback this massive enhancement of
> > the
> > negative kern doesn't show up but I only see the kerning from the font
> > itself.
> >
> > How can I access the user-defined kerns? MWE is below.
> no problem with
No, that is not my problem. The kern is correct in the output. However, I
cannot inspect the kern from within the "kerning" callback. The user-defined
kern is not added inside the kerning callback and I want to know how to query it
(see the line annotated with <--).
\input luaotfload.sty
\directlua{
local function show_kerns(head)
for item in node.traverse(head) do
if item.id == node.id("glyph") and item.char == 65 then
% Get current char and font
local nut = node.direct.todirect(item)
local char = node.direct.getchar(nut)
local font = node.direct.getfont(nut)
print(font) % <-- the kern is wrong here
% Get next char and font
local next = node.next(item)
local nextnut = node.direct.todirect(next)
local nextchar = node.direct.getchar(nextnut)
local nextfont = node.direct.getfont(nextnut)
% Determine the kern
local data = fonts.hashes.identifiers[font]
local kern = fonts.handlers.otf.getkern(data,char,nextchar)
print(kern)
end
end
end
%
luatexbase.add_to_callback("kerning",
function(head)
show_kerns(head)
node.kerning(head)
end,
"show_kerns")
}
\directlua{
fonts.handlers.otf.addfeature{
name = "ktest",
type = "kern",
data = { ["A"] = { ["V"] = -400 } } % make them overlap for the example
}
}
\font\test="Latin Modern Roman:+ktest"\test
AV
\bye
>
> \input luaotfload.sty
>
> \directlua{
> fonts.handlers.otf.addfeature{
> name = "ktest",
> type = "kern",
> data = {
> ["A"] = { ["V"] = -400 } } % make them overlap for the example
> }
> }
>
> AV
>
> \font\test="Latin Modern Roman:+ktest" at 11pt
> \test
> AV
>
> \bye
>
>
> This is LuaTeX, Version 1.07.0 (TeX Live 2018)
>
>
> Herbert
More information about the luatex
mailing list