From: Hironori Kitagawa Date: Thu, 18 Mar 2021 11:02:37 +0000 (+0900) Subject: more simplified \shipout X-Git-Tag: 20210319.0~5 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=0c82ec705532eab7e3345f4aa3460c3e435100d2;p=luatex-ja%2Fluatexja.git more simplified \shipout --- diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index f2f5d55..47b4aec 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -1113,24 +1113,8 @@ do end end end - local getbox, shipout = tex.getbox, tex.shipout - local setbox, copy = node.direct.setbox, node.direct.copy - local afbox - function luatexja.direction.shipout() - start_time_measure 'box_primitive_hook' - if (not afbox) and luatexja.afbox_number then afbox = luatexja.afbox_number end - local a = to_direct(getbox 'ltj@afbox') - local a_dir = get_box_dir(a, dir_yoko) - if a_dir~=dir_yoko then - local b = create_dir_node(a, a_dir, dir_yoko, false) - setfield(b, 'head', a); a = b - end - setfield(shipout_temp, 'head', a); finalize_inner(shipout_temp) - setbox(afbox, copy(getlist(shipout_temp))); setfield(shipout_temp, 'head',nil) - shipout(afbox) - stop_time_measure 'box_primitive_hook' - end - function luatexja.direction.shipout_lthook(head) + local copy = node.direct.copy + function luatexja.direction.shipout_lthook (head) start_time_measure 'box_primitive_hook' local a = to_direct(head) local a_dir = get_box_dir(a, dir_yoko) diff --git a/src/ltj-latex.sty b/src/ltj-latex.sty index 2302697..da98e26 100644 --- a/src/ltj-latex.sty +++ b/src/ltj-latex.sty @@ -12,7 +12,7 @@ \def\luatexjalatexLoaded{\endinput} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ltj-latex}[2021-03-17 LaTeX support of LuaTeX-ja] +\ProvidesPackage{ltj-latex}[2021-03-18 LaTeX support of LuaTeX-ja] \endlinechar=13 @@ -28,8 +28,21 @@ }{} \@ifl@t@r\fmtversion{2021-05-01}{\count@=1 }{\count@=0 } \ifnum \count@<1 +%%%% \shipout + \newluafunction\ltj@@lua@shipout@inner + \directlua{ + local t = lua.get_functions_table() + local getbox, setbox = tex.getbox, tex.setbox + local shipout_lthook = luatexja.direction.shipout_lthook + t[\the\ltj@@lua@shipout@inner]=function () + local a = shipout_lthook(getbox(\the\ltj@afbox)) + if a then setbox(\the\ltj@afbox, a) end + end + } \protected\luadef\ltj@@lua@shipout\ltj@@lua@shipout@inner - \protected\def\ltj@shipout{\ltj@afterbox\ltj@@lua@shipout} + \def\ltj@shipout@{\ltj@@lua@shipout\primitive\shipout\box\ltj@afbox}% + \protected\def\ltj@shipout{\ltj@afterbox\ltj@shipout@} + \ifprimitive\shipout\let\shipout\ltj@shipout\fi \ifcsname tex_shipout:D\endcsname \expandafter\let\csname tex_shipout:D\endcsname\ltj@shipout \fi diff --git a/src/ltj-plain.sty b/src/ltj-plain.sty index 23298da..c6f9767 100644 --- a/src/ltj-plain.sty +++ b/src/ltj-plain.sty @@ -23,9 +23,21 @@ %! ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ % LuaTeX-ja macros against plain TeX +%%%%\shipout +\newluafunction\ltj@@lua@shipout@inner +\directlua{ + local t = lua.get_functions_table() + local getbox, setbox = tex.getbox, tex.setbox + local shipout_lthook = luatexja.direction.shipout_lthook + t[\the\ltj@@lua@shipout@inner]=function () + local a = shipout_lthook(getbox(\the\ltj@afbox)) + if a then setbox(\the\ltj@afbox, a) end + end +} \protected\luadef\ltj@@lua@shipout\ltj@@lua@shipout@inner -\protected\def\ltj@shipout{\ltj@afterbox\ltj@@lua@shipout} -\let\shipout\ltj@shipout +\def\ltj@shipout@{\ltj@@lua@shipout\primitive\shipout\box\ltj@afbox}% +\protected\def\ltj@shipout{\ltj@afterbox\ltj@shipout@} +\ifprimitive\shipout\let\shipout\ltj@shipout\fi \directlua{luatexja.direction.shipout_lthook = nil} \ifdefined\ltj@stdmcfont\else\def\ltj@stdmcfont{file:HaranoAjiMincho-Regular.otf}\fi diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 75cc048..3f3f102 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -701,13 +701,6 @@ \ltj@@lua@raisebox\ltj@@orig@vcenter{\box\ltj@afbox}% } -%%%% \shipout -\newluafunction\ltj@@lua@shipout@inner -\directlua{ - local t = lua.get_functions_table() - t[\the\ltj@@lua@shipout@inner]=luatexja.direction.shipout -} - %%%% \unhbox and \unvbox \newluafunction\ltj@@lua@unboxcheckdir@inner \directlua{