local traverse_id = Dnode.traverse_id
local start_time_measure, stop_time_measure
= ltjb.start_time_measure, ltjb.stop_time_measure
+local abs = math.abs
local id_kern = node.id('kern')
local id_hlist = node.id('hlist')
local dir_tate = luatexja.dir_table.dir_tate
local dir_yoko = luatexja.dir_table.dir_yoko
local dir_dtou = luatexja.dir_table.dir_dtou
+local dir_utod = luatexja.dir_table.dir_utod
local dir_node_auto = luatexja.dir_table.dir_node_auto
local dir_node_manual = luatexja.dir_table.dir_node_manual
end
return page_direction
end
- local abs = math.abs
function get_adjust_dir_count()
for i=tex_nest.ptr, 1, -1 do
local v = tex_nest[i]
local function set_list_direction(v, name)
local lv, w = tex_nest.ptr, tex.lists.page_head
if not v then
- v,name = get_dir_count(), nil
+ v,name = get_dir_count(), nil
elseif v=='adj' then
v,name = get_adjust_dir_count(), nil
+ elseif v=='math' then
+ v,name = get_dir_count(), nil
+ if abs(tex_nest[lv].mode) == ltjs.mmode and v == dir_tate then
+ v = dir_utod
+ end
end
if tex.currentgrouptype==6 then
ltjb.package_error(
{ 'whatsit', sid_restore },
},
},
+ [dir_utod] = { -- utod 中で組む
+ width = get_w,
+ height = get_h,
+ depth = get_d,
+ [id_hlist] = {
+ { 'nop' },
+ { 'nop' },
+ { 'nop' },
+ { 'box', zero },
+ { 'nop' },
+ },
+ [id_vlist] = {
+ { 'nop' },
+ { 'nop' },
+ { 'nop' },
+ { 'box', zero },
+ { 'nop' },
+ },
+ }
},
[dir_dtou] = { -- dtou を
[dir_yoko] = { -- yoko 中で組む
},
},
}
+ dir_node_aux[dir_yoko][dir_utod] = dir_node_aux[dir_yoko][dir_tate]
+ dir_node_aux[dir_dtou][dir_utod] = dir_node_aux[dir_dtou][dir_tate]
+ dir_node_aux[dir_tate][dir_tate] = dir_node_aux[dir_tate][dir_utod]
+ dir_node_aux[dir_utod] = dir_node_aux[dir_tate]
end
-- 1st ret val: b の組方向
elseif cmd=='box' then
nn = b; setfield(b, 'next', nil)
setfield(nn, 'shift', getfield(nn, 'shift') + arg(w,h,d))
+ elseif cmd=='nop' then
+ nn = node_new(id_kern)
+ setfield(nn, 'kern', 0)
end
if db_head then
insert_after(db_head, db_tail, nn)
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
-- 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 id_frac = node.id('fraction')
local id_simple = node.id('noad')
local id_sub_mlist = node.id('sub_mlist')
+local id_whatsit = node.id('whatsit')
+local sid_user = node.subtype('user_defined')
+local DIR = luatexja.userid_table.DIR
local PROCESSED = luatexja.icflag_table.PROCESSED
return p
end
+local node_remove = Dnode.remove
luatexbase.add_to_callback('mlist_to_hlist',
function (n, display_type, penalties)
- local head = to_node(conv_jchar_to_hbox(to_direct(n), 0))
- head = node.mlist_to_hlist(head, display_type, penalties)
- return head
+ n = to_direct(n)
+ if getid(n)==id_whatsit and getsubtype(n)==sid_user and
+ getfield(n, 'user_id') == DIR then
+ local old_n = n; n = node_remove(n, n); node_free(old_n)
+ end
+ return node.mlist_to_hlist(
+ to_node(conv_jchar_to_hbox(n, 0)),
+ display_type, penalties)
end,'ltj.mlist_to_hlist', 1)
luatexja.math = { is_math_letters = is_math_letters }
\directlua{% This value depends on the version of LuaTeX.
luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode
}%
+ $\directlua{% This value depends on the version of LuaTeX.
+ luatexja.stack.mmode = -tex.nest[tex.nest.ptr].mode
+ }$%
}
\setbox0\vbox{%
\directlua{% This value depends on the version of LuaTeX.
\protected\def\dtou{%
\directlua{luatexja.direction.set_list_direction(1, 'dtou')}%
}
+\protected\def\utod{% 「縦数式ディレクション」
+ \directlua{luatexja.direction.set_list_direction(11, 'utod')}%
+}
\define@key[ltj]{japaram}{direction}{%% always local
\directlua{luatexja.direction.set_list_direction(1, 'ltjsetparameter')}%
}
end
}%
}
+%%%% 縦数式ディレクションの実装
+\everymath{%
+ \directlua{luatexja.direction.set_list_direction('math')}%
+}
+\everydisplay{%
+ \directlua{luatexja.direction.set_list_direction('math')}%
+}
+
%%%% \raise, \lower, \moveleft, \moveright
\let\ltj@@orig@raise=\raise
}\ltj@afterbox\ltj@@moveleft@a}
-%%%% unhbox and unvbox
+%%%% \unhbox and \unvbox
\let\ltj@@orig@unhbox=\unhbox
\let\ltj@@orig@unvbox=\unvbox
\protected\def\unhbox{\ltj@reset@globaldefs\afterassignment\ltj@@unhbox\ltj@tempcnta}
dir_table.dir_dtou = 1
dir_table.dir_tate = 3
dir_table.dir_yoko = 4
-dir_table.dir_node_auto = 16 -- 組方向を合わせるために自動で作られたもの
-dir_table.dir_node_manual = 32 -- 寸法代入によって作られたもの
+dir_table.dir_utod = 11 -- 「縦数式ディレクション」 in pTeX
+dir_table.dir_node_auto = 128 -- 組方向を合わせるために自動で作られたもの
+dir_table.dir_node_manual = 256 -- 寸法代入によって作られたもの
------------------------------------------------------------------------