From f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 19 Apr 2017 23:04:15 +0000 Subject: context beta/cont-tmf.zip (Apr 16 12:55) git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/context/base/mkiv/pack-box.mkiv | 111 ++++++++++++++------- 1 file changed, 77 insertions(+), 34 deletions(-) (limited to 'Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv') diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv index fad7d6e18a3..8279fcd7154 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv @@ -24,10 +24,15 @@ %D which in itself is ok, but can lead to loops due to rounding errors (happened %D in demo-obv). -\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] -\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] -\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] -\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +% \definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +% \definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +% \definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +% \definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] + +\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight] +\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight] +\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight] +\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight] \unexpanded\def\internaltextoverlay#1% will become more generic and installable {\startoverlay % i.e. probably an overlay by itself @@ -42,6 +47,10 @@ \installcorenamespace {anchor} +% produces a box too +% +% \anchor[text-1][preset=lefttop][framed settings]{HELLO WORLD} + \unexpanded\def\defineanchor {\doquadrupleempty\pack_anchors_define} @@ -64,14 +73,11 @@ {\begingroup \edef\currentanchor{#1}% \ifcsname\??anchor\currentanchor\endcsname - \expandafter\pack_anchor_predefined + \expandafter\lastnamedcs \else \expandafter\pack_anchor_notdefined \fi} -\def\pack_anchor_predefined - {\csname\??anchor\currentanchor\endcsname} - \def\pack_anchor_notdefined {\dodoubleempty\pack_anchor_notdefined_indeed} @@ -93,33 +99,72 @@ \newdimen\d_pack_anchors_height \newdimen\d_pack_anchors_depth -\definelayer[anchor] % \defineoverlay[anchor][\ruledhbox{\flushlayer[anchor]}] +% \definelayer[anchor] + +\newcount\c_pack_anchors_n +\newtoks \t_pack_anchors_flush + +\unexpanded\def\pack_anchors_register#1#2% + {\global\advance\c_pack_anchors_n\plusone + \pagereference[\v!layer:\v!anchor:\number\c_pack_anchors_n]% + \putboxincache\v!anchor{\number\c_pack_anchors_n}\b_pack_anchors + \doglobal\appendetoks + \pack_anchors_flush{\number\c_pack_anchors_n}{#1}{#2}% + \to \t_pack_anchors_flush + \glet\pack_anchors_flush_all\pack_anchors_flush_all_indeed} + +\unexpanded\def\pack_anchors_flush#1#2#3% + {\doifelseboxincache\v!anchor{#1} + {\doifelsereferencefound{\v!layer:\v!anchor:#1} + {\ifnum\currentreferencerealpage=\realpageno\relax + \setlayer[#2][#3,\c!position=\v!no]{\directboxfromcache\v!anchor{#1}}% + \else + \donetrue + \fi + }\donetrue}% + \donetrue}% + +\unexpanded\def\pack_anchors_flush_all_indeed + {\donefalse + \the\t_pack_anchors_flush + \ifdone\else + \global\t_pack_anchors_flush\emptytoks + \glet\pack_anchors_flush_all\relax + \fi} + +\let\pack_anchors_flush_all\relax + +\appendtoks + \pack_anchors_flush_all +\to \everybeforepagebody \def\pack_anchors_process_finish#1#2#3% brrr: we need to apply offset only once .. a bit messy {\checkpositionoverlays - % for the moment we ignore the depth \setbox\b_pack_anchors\box\nextbox - \d_pack_anchors_width \wd\b_pack_anchors - \d_pack_anchors_height\ht\b_pack_anchors - \d_pack_anchors_depth \dp\b_pack_anchors - \setbox\scratchbox\emptyhbox - \wd\scratchbox\d_pack_anchors_width - \ht\scratchbox\d_pack_anchors_height - \dp\scratchbox\d_pack_anchors_depth - \setlayer - [anchor] - [\c!width=\d_pack_anchors_width, - \c!height=\d_pack_anchors_height, - \c!offset=\zeropoint, - #2,#3] - {\setlayer[#1]{\box\b_pack_anchors}}% % #1 uses ovelaywidth/height - \framed % could be a predefined framed - [\c!background=anchor, - \c!offset=\v!overlay, - \c!frame=\v!off, - #3] - {\box\scratchbox}% - \endgroup} + \framed % could be a predefined framed but used seldom + [\c!offset=\v!overlay,\c!frame=\v!off,#3] + {\pack_anchors_register{#1}{#2}% + \novrule % hm, not needed as we frame the size (but kind of default) + \s!width \wd\b_pack_anchors + \s!height\ht\b_pack_anchors + \s!depth \dp\b_pack_anchors}% + \endgroup} + +% \setlayeranchored[text-1][preset=lefttop]{HELLO WORLD} produces a simple (empty) hbox +% synchronizes per page + +\unexpanded\def\setlayeranchored + {\begingroup + \dodoubleempty\pack_anchors_set_finish} + +\def\pack_anchors_set_finish[#1][#2]% + {\dowithnextbox + {\iffirstargument + \checkpositionoverlays + \setbox\b_pack_anchors\box\nextbox + \dontleavehmode\hpack{\pack_anchors_register{#1}{#2}}% + \fi + \endgroup}\hbox} % collectors @@ -147,7 +192,6 @@ \unexpanded\def\resetcollector[#1]% {\ifcsname\??collectorbox#1\endcsname - %\global\setbox\csname\??collectorbox#1\endcsname\emptybox \global\setbox\lastnamedcs\emptybox \fi} @@ -159,7 +203,6 @@ {\edef\currentcollector{#1}% \ifcsname\??collectorbox\currentcollector\endcsname \settrue\c_pack_boxes_collector_valid_box - %\expandafter\let\expandafter\b_pack_boxes_collector\csname\??collectorbox\currentcollector\endcsname \expandafter\let\expandafter\b_pack_boxes_collector\lastnamedcs \else \setfalse\c_pack_boxes_collector_valid_box @@ -573,7 +616,7 @@ \ifconditional\c_pack_boxes_t \paperheight -\MPy\currentbgposition+\MPy\currentpageposition % not checked \else\ifconditional\c_pack_boxes_b - \scratchheight+\MPy\currentbgposition-\MPy\currentpageposition % not checked + \scratchheight+\MPy\currentbgposition-\MPy\currentpageposition + \MPh\currentbgposition % not checked (\MPh added) \else \scratchheight \fi\fi -- cgit v1.2.3