-
Notifications
You must be signed in to change notification settings - Fork 3
/
luametalatex-oldnode.lua
79 lines (68 loc) · 2.15 KB
/
luametalatex-oldnode.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-- Provide enough compatibility functions in the node module to make LuaTeX code happy.
--
local direct = node.direct
--
-- These were added for luaotfload
local properties = direct.get_properties_table()
local flush = direct.flush_list
local meta = {__gc = function(t) if t.components then flush(t.components) end end}
function direct.getcomponents(n)
local props = properties[n]
return props and props.components and props.components.components
end
function 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
local props_comp = rawget(props, 'components')
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 = direct.mlist_to_hlist
local todirect = direct.todirect
local tonode = direct.tonode
function node.mlist_to_hlist(n, ...)
return tonode(mlist_to_hlist(todirect(n), ...))
end
-- For luapstricks we also need
local hpack = direct.hpack
function node.hpack(n, ...)
local h, b = hpack(todirect(n), ...)
return tonode(h), b
end
-- Originally for lua-widow-control
local slide = direct.slide
local vpack = direct.vpack
local find_attribute = direct.find_attribute
local effective_glue = direct.effective_glue
function node.slide(n) return tonode(slide(todirect(n))) end
function node.vpack(n, ...)
local v, b = vpack(todirect(n), ...)
return tonode(v), b
end
function node.find_attribute(n, id)
local val, found = find_attribute(todirect(n), id)
if val then
return val, tonode(found)
end
end
function node.effective_glue(n, m, round)
return effective_glue(todirect(n), todirect(m), round)
end
--
local has_attribute = direct.has_attribute
local kerning = direct.kerning
function node.has_attribute(n, ...) return has_attribute(todirect(n), ...) end
function node.kerning(h, t)
local h, t, s = kerning(todirect(h), todirect(t))
return tonode(h), tonode(t), s
end