summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty50
1 files changed, 36 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty
index a4b340136a3..a9ca6a2c140 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty
@@ -2,37 +2,59 @@
% lltjp-atbegshi.sty
%
-\newif\ifltj@ltshipout@avail
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-atbegshi}[2020-09-13 Patching \string\shipout\space hooks for LuaTeX-ja]
-\@ifl@t@r\fmtversion{2020-10-01}{%
- \ifnum\patch@level<0\relax \ifnum\patch@level<-6 \ltj@ltshipout@availtrue\fi
- \else\ltj@ltshipout@availtrue\fi
-}{}
-\ifltj@ltshipout@avail\else\RequirePackage{atbegshi}\fi
+\ProvidesPackage{lltjp-atbegshi}[2020-09-30 Patching \string\shipout\space hooks for LuaTeX-ja]
% concept: execute all hooks inside yoko direction \vbox
-\ifltj@ltshipout@avail
+\ifltj@ltfilehook@avail
%<*ltshipout>-----------------------------------
%
\RequirePackage{expl3}
\ExplSyntaxOn\makeatletter
\box_new:N \l__platex_shipout_dummy_box
-\tl_put_left:Nn {\__shipout_execute_cont:}
- {\tex_setbox:D \l__platex_shipout_dummy_box \tex_vbox:D \c_group_begin_token \yoko }
-\tl_put_right:Nn {\__shipout_execute_cont:} {\c_group_end_token}
-\ExplSyntaxOff
+\cs_new_eq:NN \__platex_original_shipout_execute_cont: \__shipout_execute_cont:
+\cs_set:Npn \__shipout_execute_cont:
+{
+ % if \l_shipout_box is not a \yoko-box (= horizontal writing),
+ % then make it a \yoko-box behorehand.
+ \platex_if_box_yoko:NF \l_shipout_box {
+ \vbox_set:Nn \l_shipout_box { \platex_direction_yoko: \box_use:N \l_shipout_box }
+ }
+ % if the current direction is not \yoko,
+ % then enclose \__shipout_execute_cont: with
+ % a dummy \yoko-box named \l__platex_shipout_dummy_box.
+ \platex_if_direction_yoko:TF {
+ \__platex_original_shipout_execute_cont:
+ }{
+ \vbox_set:Nn \l__platex_shipout_dummy_box {
+ \platex_direction_yoko: \__platex_original_shipout_execute_cont:
+ }
+ % [Limitation] the code above may discard some contents,
+ % so we'd like to put it back by \box\l__platex_shipout_dummy_box.
+ % however, an infinite loop occurs if we uncomment the line below
+ % so we can't.
+ %\box_use:N \l__platex_shipout_dummy_box
+ }
+}
%</ltshipout>-----------------------------------
-
+\ExplSyntaxOff
\expandafter\endinput
\fi
-\AtBeginShipoutInit
+\RequirePackage{atbegshi}
%<*atbegshi>-------------------------------------
% patching atbegshi.sty
%%% following codes are almost copied from
%%% pxatbegshi.sty 2019/09/07 v0.5 (in platex-tools bundle, by H. Yamashita).
+\ifdefined\AtBeginShipoutOriginalShipout
+ \let\AtBeginShipoutOriginalShipout\ltj@shipout
+\fi
+\AtBeginShipoutInit
+\DeclareRobustCommand \AtBeginDvi [1]{%
+ \global \setbox \@begindvibox
+ \vbox{\yoko\unvbox \@begindvibox #1}%
+}
%% internal macros are locally effective
\begingroup