OSDN Git Service

more simplified \shipout
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 18 Mar 2021 11:02:37 +0000 (20:02 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 18 Mar 2021 11:02:37 +0000 (20:02 +0900)
src/ltj-direction.lua
src/ltj-latex.sty
src/ltj-plain.sty
src/luatexja-core.sty

index f2f5d55..47b4aec 100644 (file)
@@ -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)
index 2302697..da98e26 100644 (file)
@@ -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
 
 }{}
 \@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
index 23298da..c6f9767 100644 (file)
 %! ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 % 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
index 75cc048..3f3f102 100644 (file)
   \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{