luametalatex/luametalatex-node-luaotfload.lua

37 lines
1.1 KiB
Lua
Raw Normal View History

2020-06-16 21:15:23 +02:00
-- Provide enough compatibility functions to make luaotfload happy
2020-06-04 09:27:24 +02:00
local properties = node.direct.get_properties_table()
local flush = node.direct.flush_list
local meta = {__gc = function(t) if t.components then flush(t.components) end end}
function node.direct.getcomponents(n)
local props = properties[n]
return props and props.components and props.components.components
end
function node.direct.setcomponents(n, comp)
local props = properties[n]
if not props then
if not comp then return end
props = {components = setmetatable({components = comp}, meta)}
properties[n] = props
return
end
2020-06-16 21:15:23 +02:00
local props_comp = rawget(props, 'components')
2020-06-04 09:27:24 +02:00
if props_comp then
props_comp.components = comp -- Important even if nil to avoid double-free
if not comp then props.components = nil end
elseif not comp then
else
props.components = setmetatable({components = comp}, meta)
end
end
local mlist_to_hlist = node.direct.mlist_to_hlist
local todirect = node.direct.todirect
local tonode = node.direct.tonode
function node.mlist_to_hlist(n, ...)
return tonode(mlist_to_hlist(todirect(n), ...))
end