diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 141 |
1 files changed, 100 insertions, 41 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 12da7598665..c86a1ebeef2 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3candidates.dtx 3633 2012-05-12 20:11:32Z joseph $ +\GetIdInfo$Id: l3candidates.dtx 4298 2012-11-09 13:34:43Z joseph $ {L3 Experimental additions to l3kernel} %</driver|package> %<*driver> @@ -210,9 +210,10 @@ % Material output of the bounding box will still be displayed in the output % unless \cs{box_clip:N} is subsequently applied. % The updated \meta{box} will be an -% hbox, irrespective of the nature of the \meta{box} before the viewport +% hbox, irrespective of the nature of the \meta{box} before the trim % operation is applied. The adjustment applies within the current \TeX{} -% group level. +% group level. The behavior of the operation where the trims requested is +% greater than the size of the box is undefined. % \end{function} % % \begin{function}{\box_viewport:Nnnnn, \box_viewport:cnnnn} @@ -1290,7 +1291,12 @@ } { \box_set_wd:Nn \l_@@_internal_box { \l_@@_right_new_dim } - \box_use:N \l_@@_internal_box + \hbox:n + { + \tex_kern:D \c_zero_dim + \box_use:N \l_@@_internal_box + \tex_hss:D + } } } % \end{macrocode} @@ -1308,67 +1314,114 @@ % \end{macro} % % \begin{macro}{\box_trim:Nnnnn, \box_trim:cnnnn} -% Trimming from the left- and right-hand edges of the box is easy. The total -% width is set to remove from the right, and a skip will shift the material -% to remove from the left. +% Trimming from the left- and right-hand edges of the box is easy: kern the +% appropriate parts off each side. % \begin{macrocode} \cs_new_protected:Npn \box_trim:Nnnnn #1#2#3#4#5 { - \box_set_wd:Nn #1 { \box_wd:N #1 - (#4) - (#2) } - \hbox_set:Nn #1 + \hbox_set:Nn \l_@@_internal_box { - \skip_horizontal:n { - \dim_eval:n {#2} } + \tex_kern:D -\__dim_eval:w #2 \__dim_eval_end: \box_use:N #1 + \tex_kern:D -\__dim_eval:w #4 \__dim_eval_end: } % \end{macrocode} % For the height and depth, there is a need to watch the baseline is % respected. Material always has to stay on the correct side, so trimming -% has to check that there is enough material to trim. +% has to check that there is enough material to trim. First, the bottom +% edge. If there is enough depth, simply set the depth, or if not move +% down so the result is zero depth. \cs{box_move_down:nn} is used in both +% cases so the resulting box always contains a \tn{lower} primitive. +% The internal box is used here as it allows safe use of \cs{box_set_dp:Nn}. % \begin{macrocode} \dim_compare:nNnTF { \box_dp:N #1 } > {#3} - { \box_set_dp:Nn #1 { \box_dp:N #1 - (#3) } } { - \hbox_set:Nn #1 - { \box_move_down:nn { #3 - \box_dp:N #1 } { \box_use:N #1 } } - \box_set_dp:Nn #1 \c_zero_dim + \hbox_set:Nn \l_@@_internal_box + { + \box_move_down:nn \c_zero_dim + { \box_use:N \l_@@_internal_box } + } + \box_set_dp:Nn \l_@@_internal_box { \box_dp:N #1 - (#3) } + } + { + \hbox_set:Nn \l_@@_internal_box + { + \box_move_down:nn { #3 - \box_dp:N #1 } + { \box_use:N \l_@@_internal_box } + } + \box_set_dp:Nn \l_@@_internal_box \c_zero_dim + } +% \end{macrocode} +% Same thing, this time from the top of the box. +% \begin{macrocode} + \dim_compare:nNnTF { \box_ht:N \l_@@_internal_box } > {#5} + { + \hbox_set:Nn \l_@@_internal_box + { \box_move_up:nn \c_zero_dim { \box_use:N \l_@@_internal_box } } + \box_set_ht:Nn \l_@@_internal_box + { \box_ht:N \l_@@_internal_box - (#5) } } - \dim_compare:nNnTF { \box_ht:N #1 } > {#5} - { \box_set_ht:Nn #1 { \box_ht:N #1 - (#5) } } { - \hbox_set:Nn #1 - { \box_move_up:nn { #5 - \box_ht:N #1 } { \box_use:N #1 } } - \box_set_ht:Nn #1 \c_zero_dim + \hbox_set:Nn \l_@@_internal_box + { + \box_move_up:nn { #5 - \box_ht:N \l_@@_internal_box } + { \box_use:N \l_@@_internal_box } + } + \box_set_ht:Nn \l_@@_internal_box \c_zero_dim } + \box_set_eq:NN #1 \l_@@_internal_box } \cs_generate_variant:Nn \box_trim:Nnnnn { c } % \end{macrocode} % \end{macro} % % \begin{macro}{\box_viewport:Nnnnn, \box_viewport:cnnnn} -% The same general logic as for clipping, but with absolute dimensions. -% Thus again width is easy and height is harder. +% The same general logic as for the trim operation, but with absolute +% dimensions. As a result, there are some things to watch out for in the +% vertical direction. % \begin{macrocode} \cs_new_protected:Npn \box_viewport:Nnnnn #1#2#3#4#5 { - \box_set_wd:Nn #1 { (#4) - (#2) } - \hbox_set:Nn #1 + \hbox_set:Nn \l_@@_internal_box { - \skip_horizontal:n { - \dim_eval:n {#2} } + \tex_kern:D -\__dim_eval:w #2 \__dim_eval_end: \box_use:N #1 + \tex_kern:D \__dim_eval:w #4 - \box_wd:N #1 \__dim_eval_end: + } + \dim_compare:nNnTF {#3} < \c_zero_dim + { + \hbox_set:Nn \l_@@_internal_box + { + \box_move_down:nn \c_zero_dim + { \box_use:N \l_@@_internal_box } + } + \box_set_dp:Nn \l_@@_internal_box { -\dim_eval:n {#3} } } - \dim_compare:nNnTF {#3} > \c_zero_dim { - \hbox_set:Nn #1 { \box_move_down:nn {#3} { \box_use:N #1 } } - \box_set_dp:Nn #1 \c_zero_dim + \hbox_set:Nn \l_@@_internal_box + { \box_move_down:nn {#3} { \box_use:N \l_@@_internal_box } } + \box_set_dp:Nn \l_@@_internal_box \c_zero_dim } - { \box_set_dp:Nn #1 { - \dim_eval:n {#3} } } \dim_compare:nNnTF {#5} > \c_zero_dim - { \box_set_ht:Nn #1 {#5} } { - \hbox_set:Nn #1 - { \box_move_up:nn { -\dim_eval:n {#5} } { \box_use:N #1 } } - \box_set_ht:Nn #1 \c_zero_dim + \hbox_set:Nn \l_@@_internal_box + { \box_move_up:nn \c_zero_dim { \box_use:N \l_@@_internal_box } } + \box_set_ht:Nn \l_@@_internal_box + { + #5 + \dim_compare:nNnT {#3} > \c_zero_dim + { - (#3) } + } } + { + \hbox_set:Nn \l_@@_internal_box + { + \box_move_up:nn { -\dim_eval:n {#5} } + { \box_use:N \l_@@_internal_box } + } + \box_set_ht:Nn \l_@@_internal_box \c_zero_dim + } + \box_set_eq:NN #1 \l_@@_internal_box } \cs_generate_variant:Nn \box_viewport:Nnnnn { c } % \end{macrocode} @@ -1720,12 +1773,15 @@ % has the reference point at the bottom-left. The $x$-direction is % handled by moving the content by the difference in the positions of % the bounding box and the content left edge. The $y$-direction is -% dealt with by moving the box down by any depth it has acquired. +% dealt with by moving the box down by any depth it has acquired. The +% internal box is used here to allow for the next step. % \begin{macrocode} - \hbox_set:Nn #1 + \hbox_set:Nn \l_@@_internal_box { - \tex_kern:D \l_@@_bounding_shift_dim - \tex_kern:D -\l_@@_left_corner_dim + \tex_kern:D + \__dim_eval:w + \l_@@_bounding_shift_dim - \l_@@_left_corner_dim + \__dim_eval_end: \box_move_down:nn { \l_@@_bottom_corner_dim } { \box_use:N #1 } } @@ -1733,13 +1789,16 @@ % If there have been any previous rotations then the size of the % bounding box will be bigger than the contents. This can be corrected % easily by setting the size of the box to the height and width of the -% content. +% content. As this operation requires setting box dimensions and these +% transcend grouping, the safe way to do this is to use the internal box +% and to reset the result into the target box. % \begin{macrocode} - \box_set_ht:Nn #1 + \box_set_ht:Nn \l_@@_internal_box { \l_@@_top_corner_dim - \l_@@_bottom_corner_dim } - \box_set_dp:Nn #1 { 0 pt } - \box_set_wd:Nn #1 + \box_set_dp:Nn \l_@@_internal_box { 0 pt } + \box_set_wd:Nn \l_@@_internal_box { \l_@@_right_corner_dim - \l_@@_left_corner_dim } + \hbox_set:Nn #1 { \box_use:N \l_@@_internal_box } % \end{macrocode} % The final task is to move the poles and corners such that they are % back in alignment with the box reference point. |