[luatex] How to query fonts.handlers

Henri Menke henrimenke at gmail.com
Wed Feb 6 10:01:24 CET 2019


On 2/6/19 9:54 PM, Ulrike Fischer wrote:
> Am Wed, 6 Feb 2019 13:10:04 +1300 schrieb Henri Menke:
> 
>> I have a working ConTeXt solution now, but I can't get the same thing to
>> work in plain LuaTeX.
> 
> What doesn't work?

This MWE crashes because lookupcache is nil.

\input luaotfload.sty

\directlua{
    fonts.handlers.otf.addfeature {
        name = "ktest",
        type = "kern",
        data = {
            ["t"] = { ["e"] = 500 },
        }
    }
}

\font\1="file:lmroman10-regular.otf:mode=node;+ktest;" at 10pt

\1 test \directlua{
     local fnt = font.current()
     local tfmdata = fonts.hashes.identifiers[fnt]
     local t = string.byte("t")
     local e = string.byte("e")
     local kern = 0
     for kind in pairs(tfmdata.shared.rawdata.lookupcache) do
         kern = kern + fonts.handlers.otf.getkern(tfmdata,t,e,kind)
     end
     tex.sprint(kern / tfmdata.parameters.factor) % 500
}

\bye


> 
> \directlua{
>      local fnt = font.current()
>      local tfmdata = fonts.hashes.identifiers[fnt]
>      local t = string.byte("t")
>      local e = string.byte("e")
>      local kern = 0
>      for _,kind in
> pairs(table.keys(tfmdata.shared.rawdata.lookupcache)) do
>          kern = kern + fonts.handlers.otf.getkern(tfmdata,t,e,kind)
>      end
>      tex.sprint(kern / tfmdata.parameters.factor) }
> 
> works fine for me (my fontloader is a bit newer, but I doubt that it
> matters).
> 
> 



More information about the luatex mailing list