-------------------- Handling of TeX values
do
- local glue_spec_id = node.id("glue_spec")
-
- local function copy_skip(s1, s2)
- if not s1 then
- s1 = node.new(glue_spec_id)
- end
- s1.width = s2.width or 0
- s1.stretch = s2.stretch or 0
- s1.stretch_order = s2.stretch_order or 0
- s1.shrink = s2.shrink or 0
- s1.shrink_order = s2.shrink_order or 0
- return s1
- end
-
--! ixbase.to_dimen() と同じ
local function to_dimen(val)
if val == nil then
return tex.sp(val), fil
end
---! ixbase.to_skip() と同じ
- local function to_skip(val)
- if type(val) == "userdata" then
- return val
- end
- local res = node.new(glue_spec_id)
- if val == nil then
- res.width = 0
- elseif type(val) == "number" then
- res.width = val
- elseif type(val) == "table" then
- copy_skip(res, val)
- else
- local t = tostring(val):lower():explode()
- local w, p, m = t[1], t[3], t[5]
- if t[2] == "minus" then
- p, m = nil, t[3]
- end
- res.width = tex.sp(t[1])
- if p then
- res.stretch, res.stretch_order = parse_dimen(p)
- end
- if m then
- res.shrink, res.shrink_order = parse_dimen(m)
- end
- end
- return res
- end
-
- local function dump_skip(s)
- print(("%s+%s<%s>-%s<%s>"):format(
- s.width or 0, s.stretch or 0, s.stretch_order or 0,
- s.shrink or 0, s.shrink_order or 0))
- end
-
ltjb.to_dimen = to_dimen
- ltjb.dump_skip = dump_skip
- ltjb.to_skip = to_skip
end
-------------------- Virtual table for LaTeX counters
}
}
-%% \ltj@safe@glue{<glue>}
-%! グルー値.
-% For a glue. The result is a gluespec object.
-\def\ltj@safe@glue{
- \ltj@safe@glue@or\ltj@safe@invalid
-}
-\def\ltj@safe@glue@or#1#2{
- \expandafter\expandafter\expandafter\ltj@@safe@glueA
- \ltj@gobble@glue#2\ltj@@safe@end{#2}{#1}
-}
-\def\ltj@@safe@glueA#1\ltj@@safe@end#2#3{
- \ltj@if@blank{#1}{
- (luatexja.base.to_skip("\the\glueexpr#2\relax"))
- }{
- #3
- }
-}
-
%% \ltj@safe@real{<real>}
%! 実数. これは十進表記に限る.
% For a real number given in decimal notation or a macro that
--
luatexbase.provides_module({
name = 'luatexja.charrange',
- date = '2014/05/08',
+ date = '2014/06/03',
description = 'Handling the range of Japanese characters',
})
module('luatexja.charrange', package.seeall)
luatexja.load_module('base'); local ltjb = luatexja.base
-local Dnode = node.direct or node
-local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
-local has_attr = Dnode.has_attribute
+local getchar = node.direct.getchar
+local has_attr = node.direct.has_attribute
local has_attr_node = node.has_attribute
local tex_getattr = tex.getattribute
local attr_icflag = luatexbase.attributes['ltj@icflag']
local cat_lp = luatexbase.catcodetables['latex-package']
-local Dnode = node.direct or node
-local nullfunc = function (n) return n end
-local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
-local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-local has_attr = Dnode.has_attribute
-local set_attr = Dnode.set_attribute
-local insert_before = Dnode.insert_before
-local insert_after = Dnode.insert_after
-local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
-local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end
-local getlist = (Dnode ~= node) and Dnode.getlist or function(n) return n.head end
-local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
-local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
-local node_new = Dnode.new
-local node_tail = Dnode.tail
-local node_free = Dnode.free
-local node_remove = Dnode.remove
-local node_next = (Dnode ~= node) and Dnode.getnext or node.next
-local traverse = Dnode.traverse
-local traverse_id = Dnode.traverse_id
+local to_node = node.direct.tonode
+local to_direct = node.direct.todirect
+local has_attr = node.direct.has_attribute
+local set_attr = node.direct.set_attribute
+local insert_before = node.direct.insert_before
+local insert_after = node.direct.insert_after
+local getid = node.direct.getid
+local getsubtype = node.direct.getsubtype
+local getlist = node.direct.getlist
+local setfield = node.direct.setfield
+local getfield = node.direct.getfield
+local node_new = node.direct.new
+local node_tail = node.direct.tail
+local node_free = node.direct.free
+local node_remove = node.direct.remove
+local node_next = node.direct.getnext
+local traverse = node.direct.traverse
+local traverse_id = node.direct.traverse_id
local start_time_measure, stop_time_measure
= ltjb.start_time_measure, ltjb.stop_time_measure
local abs = math.abs
--
local dir_pool
do
- local node_copy = Dnode.copy
+ local node_copy = node.direct.copy
dir_pool = {}
for _,i in pairs({dir_tate, dir_yoko, dir_dtou, dir_utod}) do
local w = node_new(id_whatsit, sid_user)
end
local shift_old, b_dir, wh = nil, get_box_dir(bh, 0)
if wh then
- Dnode.flush_list(getfield(wh, 'value'))
+ node.direct.flush_list(getfield(wh, 'value'))
setfield(wh, 'value', nil)
end
return nh, nb, bh, b_dir
-- dir_node としてカプセル化されている
local _, dnc = get_box_dir(b, 0)
if dnc then -- free all other dir_node
- Dnode.flush_list(getfield(dnc, 'value'))
+ node.direct.flush_list(getfield(dnc, 'value'))
setfield(dnc, 'value', nil)
end
set_attr(b, attr_dir, box_dir%dir_math_mod + dir_node_auto)
db=x; break
end
end
- Dnode.flush_list(getfield(dn, 'value'))
+ node.direct.flush_list(getfield(dn, 'value'))
setfield(dn, 'value', nil)
db = db or create_dir_node(b, box_dir, new_dir, false)
local w = getfield(b, 'width')
end
-- lastbox
- local node_prev = (Dnode~=node) and Dnode.getprev or node.prev
+ local node_prev = (node.direct~=node) and node.direct.getprev or node.prev
local function lastbox_hook()
start_time_measure('box_primitive_hook')
local bn = tex_nest[tex_nest.ptr].tail
end
local _, wh = get_box_dir(b, 0) -- clean dir_node attached to the box
if wh then
- Dnode.flush_list(getfield('value', wh))
+ node.direct.flush_list(getfield('value', wh))
setfield(wh, 'value', nil)
end
end
end
do
- local getbox, setbox, copy_list = tex.getbox, tex.setbox, Dnode.copy_list
+ local getbox, setbox, copy_list = tex.getbox, tex.setbox, node.direct.copy_list
-- raise, lower
function luatexja.direction.raise_box()
start_time_measure('box_primitive_hook')
'luatexja',
'Direction Incompatible',
"\\vadjust's argument and outer vlist must have same direction.")
- Dnode.last_node()
+ node.direct.last_node()
end
end
stop_time_measure('box_primitive_hook')
end
end
local getbox = tex.getbox
- local setbox, copy = Dnode.setbox, Dnode.copy
+ local setbox, copy = node.direct.setbox, node.direct.copy
local lua_mem_kb = 0
function luatexja.direction.finalize()
local a = to_direct(tex.getbox("AtBeginShipoutBox"))
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2016/03/31',
+ date = '2016/04/03',
description = 'Loader for Japanese fonts',
})
module('luatexja.jfont', package.seeall)
luatexja.load_module('rmlgbm'); local ltjr = luatexja.rmlgbm
luatexja.load_module('direction'); local ltjd = luatexja.direction
+local setfield = node.direct.setfield
+local getid = node.direct.getid
+local to_direct = node.direct.todirect
-local Dnode = node.direct or node
-
-local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
-local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
-
-local nullfunc = function(n) return n end
-local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-
-local node_new = Dnode.new
-local node_free = Dnode.free
-local has_attr = Dnode.has_attribute
-local set_attr = Dnode.set_attribute
+local node_new = node.direct.new
+local node_free = node.direct.free
+local has_attr = node.direct.has_attribute
+local set_attr = node.direct.set_attribute
local round = tex.round
local font_getfont = font.getfont
-- MISC
------------------------------------------------------------------------
do
- local getfont = (Dnode ~= node) and Dnode.getfont or function(n) return n.font end
- local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
+ local getfont = node.direct.getfont
+ local getchar = node.direct.getchar
local get_dir_count = ltjd.get_dir_count
local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
local ensure_tex_attr = ltjb.ensure_tex_attr
- local node_write = Dnode.write
+ local node_write = node.direct.write
local font = font
local new_ic_kern
if status.luatex_version>=89 then
luatexja.load_module('stack'); local ltjs = luatexja.stack
luatexja.load_module('setwidth'); local ltjw = luatexja.setwidth
-local Dnode = node.direct or node
-
-local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
-local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
-local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
-local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end
-local getlist = (Dnode ~= node) and Dnode.getlist or function(n) return n.head end
+local setfield = node.direct.setfield
+local getfield = node.direct.getfield
+local getid = node.direct.getid
+local getsubtype = node.direct.getsubtype
+local getlist = node.direct.getlist
-- getlist cannot be used for sub_box nodes. Use instead λp. getfield(p, 'head')
-local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
-
-local nullfunc = function(n) return n end
-local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
-local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-
-local node_traverse = Dnode.traverse
-local node_new = Dnode.new
-local node_next = (Dnode ~= node) and Dnode.getnext or node.next
-local node_remove = Dnode.remove
-local node_free = Dnode.free
-local has_attr = Dnode.has_attribute
-local set_attr = Dnode.set_attribute
+local getchar = node.direct.getchar
+
+local to_node = node.direct.tonode
+local to_direct = node.direct.todirect
+
+local node_traverse = node.direct.traverse
+local node_new = node.direct.new
+local node_next = node.direct.getnext
+local node_remove = node.direct.remove
+local node_free = node.direct.free
+local has_attr = node.direct.has_attribute
+local set_attr = node.direct.set_attribute
local tex_getcount = tex.getcount
local attr_jchar_class = luatexbase.attributes['ltj@charclass']
return p
end
-local node_remove = Dnode.remove
luatexbase.add_to_callback('mlist_to_hlist',
function (n, display_type, penalties)
n = to_direct(n); list_dir = ltjd_get_dir_count()
local id_whatsit = node.id('whatsit')
local sid_user = node.subtype('user_defined')
-local Dnode = node.direct or node
+local setfield = node.direct.setfield
+local getfield = node.direct.getfield
+local getid = node.direct.getid
+local getfont = node.direct.getfont
+local getchar = node.direct.getchar
+local getsubtype = node.direct.getsubtype
-local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
-local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
-local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
-local getfont = (Dnode ~= node) and Dnode.getfont or function(n) return n.font end
---local getlist = (Dnode ~= node) and Dnode.getlist or function(n) return n.head end
-local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
-local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end
+local to_node = node.direct.tonode
+local to_direct = node.direct.todirect
-local nullfunc = function(n) return n end
-local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
-local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-
-local node_new = Dnode.new
-local node_remove = Dnode.remove
-local node_next = (Dnode ~= node) and Dnode.getnext or node.next
-local node_free = Dnode.free
-local has_attr = Dnode.has_attribute
-local set_attr = Dnode.set_attribute
-local unset_attr = Dnode.unset_attribute
-local node_insert_after = Dnode.insert_after
-local node_write = Dnode.write
-local node_traverse_id = Dnode.traverse_id
+local node_new = node.direct.new
+local node_remove = node.direct.remove
+local node_next = node.direct.getnext
+local node_free = node.direct.free
+local has_attr = node.direct.has_attribute
+local set_attr = node.direct.set_attribute
+local unset_attr = node.direct.unset_attribute
+local node_insert_after = node.direct.insert_after
+local node_write = node.direct.write
+local node_traverse_id = node.direct.traverse_id
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
luatexja.load_module('jfont'); local ltjf = luatexja.jfont
luatexja.load_module('direction'); local ltjd = luatexja.direction
-local Dnode = node.direct or node
+local to_node = node.direct.tonode
+local to_direct = node.direct.todirect
-local nullfunc = function(n) return n end
-local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
-local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-
-local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
-local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
-local getfont = (Dnode ~= node) and Dnode.getfont or function(n) return n.font end
-local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
-local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
-local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end
+local setfield = node.direct.setfield
+local getid = node.direct.getid
+local getfont = node.direct.getfont
+local getchar = node.direct.getchar
+local getfield = node.direct.getfield
+local getsubtype = node.direct.getsubtype
local pairs = pairs
local floor = math.floor
-local has_attr = Dnode.has_attribute
-local set_attr = Dnode.set_attribute
-local node_traverse = Dnode.traverse
-local node_remove = Dnode.remove
-local node_next = (Dnode ~= node) and Dnode.getnext or node.next
-local node_free = Dnode.free
-local node_end_of_math = Dnode.end_of_math
+local has_attr = node.direct.has_attribute
+local set_attr = node.direct.set_attribute
+local node_traverse = node.direct.traverse
+local node_remove = node.direct.remove
+local node_next = node.direct.getnext
+local node_free = node.direct.free
+local node_end_of_math = node.direct.end_of_math
local tex_getcount = tex.getcount
local id_glyph = node.id('glyph')
node_free(p)
end
if ltjs.list_dir == dir_tate then
- for p in Dnode.traverse_id(id_glyph,to_direct(head)) do
+ for p in node.direct.traverse_id(id_glyph,to_direct(head)) do
if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then
local pc = ltjs_orig_char_table[p]
local nf = ltjf_replace_altfont( has_attr(p, attr_curtfnt) or getfont(p) , pc)