1

When LuaLaTeX/fontspec uses a font, say Erewhon-Regular.otf, it creates a file erewhon-regular.lua that is put in (user's)Library/texlive/2022/texmf-var/luatex-cache/generic/fonts/otl/. Actually it is the lua version of the OpenType table of this font. This file may be read, e.g., with loadfile from a lua program. The same OpenType info could be gained with luacode+luaotfload functions such as fonts.hashes.identifiers[font.current()]. Curiously, some info are the same in both way, sometime not. In that case, strange result occur such as rot13 or collapse...

Example:

\documentclass{scrartcl}%
\usepackage{fontspec,luacode,luaotfload}
\begin{luacode*}
    
function check()
print("type of myt=",type(myt))
print("cache_version= ",myt.cache_version)
print("creator= ",myt.creator)  
print("tableversion= ",myt.tableversion)                    
  local mygsub=myt.resources.features.gsub
    for k, v in pairs(mygsub) do print("k=",k) print(" v=",v)
     end
end-- check 

function OT()-- 
    fff = assert (loadfile ("/Users/jacquesandre/Library/texlive/2022/texmf-var/luatex-cache/generic/fonts/otl/erewhon-regular.lua"))-- user dependent
myt=fff() 

print("FROM FILE .lua")
check()

local f  = fonts.hashes.identifiers[font.current()] 
myt=f.shared.rawdata

print("FROM FONT .lua")
check()

end--OT
  
\end{luacode*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\OT#1{\directlua{OT"#1"}}
\begin{document}
\fontspec{Erewhon-Regular}%or any other font
\OT{}
\end{document}
...

The output is as follows (extracts):

...
FROM FILE .lua
type of myt=    table
cache_version=  3.119
creator=    context mkiv
tableversion=   0.004
k=  ss02
 v= 212
k=  aalt
 v= 219
k=  tnum
 v= 215


FROM FILE .lua
type of myt=    table
cache_version=  3.119
creator=    context mkiv
tableversion=   0.004
k=  ss02
 v= 212
k=  aalt
 v= 219
k=  tnum
 v= 215

k=  rot13
 v= table: 0x600001f8f580

k=  collapse
 v= table: 0x600001f95080
etc.

What's wrong in my program?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.