diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 714 |
1 files changed, 75 insertions, 639 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index a96bc8c8f4e..627f4eba9e0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2017/04/01} +% \date{Released 2017/05/13} % % \maketitle % @@ -84,125 +84,6 @@ % % \section{Additions to \pkg{l3box}} % -% \subsection{Affine transformations} -% -% Affine transformations are changes which (informally) preserve straight -% lines. Simple translations are affine transformations, but are better handled -% in \TeX{} by doing the translation first, then inserting an unmodified box. -% On the other hand, rotation and resizing of boxed material can best be -% handled by modifying boxes. These transformations are described here. -% -% \begin{function}{\box_resize:Nnn, \box_resize:cnn} -% \begin{syntax} -% \cs{box_resize:Nnn} \meta{box} \Arg{x-size} \Arg{y-size} -% \end{syntax} -% Resize the \meta{box} to \meta{x-size} horizontally and \meta{y-size} -% vertically (both of the sizes are dimension expressions). -% The \meta{y-size} is the vertical size (height plus depth) of -% the box. The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the resizing is applied. Negative sizes will -% cause the material in the \meta{box} to be reversed in direction, but the -% reference point of the \meta{box} will be unchanged. -% Thus negative $y$-sizes will result in a box a depth dependent on the -% height of the original box a height dependent on the depth. -% The resizing applies within the current \TeX{} group level. -% \end{function} -% -% \begin{function} -% {\box_resize_to_ht_plus_dp:Nn, \box_resize_to_ht_plus_dp:cn} -% \begin{syntax} -% \cs{box_resize_to_ht_plus_dp:Nn} \meta{box} \Arg{y-size} -% \end{syntax} -% Resize the \meta{box} to \meta{y-size} vertically, scaling the horizontal -% size by the same amount (\meta{y-size} is a dimension expression). -% The \meta{y-size} is the vertical size (height plus depth) of -% the box. -% The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the resizing is applied. A negative size will -% cause the material in the \meta{box} to be reversed in direction, but the -% reference point of the \meta{box} will be unchanged. -% Thus negative $y$-sizes will result in a box with depth dependent on the -% height of the original box and height dependent on the depth of the original. -% The resizing applies within the current \TeX{} group level. -% \end{function} -% -% \begin{function} -% {\box_resize_to_ht:Nn, \box_resize_to_ht:cn} -% \begin{syntax} -% \cs{box_resize_to_ht:Nn} \meta{box} \Arg{y-size} -% \end{syntax} -% Resize the \meta{box} to \meta{y-size} vertically, scaling the horizontal -% size by the same amount (\meta{y-size} is a dimension expression). -% The \meta{y-size} is the height only, not including depth, of -% the box. -% The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the resizing is applied. -% A negative size will -% cause the material in the \meta{box} to be reversed in direction, but the -% reference point of the \meta{box} will be unchanged. -% Thus negative $y$-sizes will result in a box with depth dependent on the -% height of the original box and height dependent on the depth of the original. -% The resizing applies within the current \TeX{} group level. -% \end{function} -% -% \begin{function}{\box_resize_to_wd:Nn, \box_resize_to_wd:cn} -% \begin{syntax} -% \cs{box_resize_to_wd:Nn} \meta{box} \Arg{x-size} -% \end{syntax} -% Resize the \meta{box} to \meta{x-size} horizontally, scaling the vertical -% size by the same amount (\meta{x-size} is a dimension expression). -% The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the resizing is applied. A negative size will -% cause the material in the \meta{box} to be reversed in direction, but the -% reference point of the \meta{box} will be unchanged. -% Thus negative $y$-sizes will result in a box a depth dependent on the -% height of the original box a height dependent on the depth. -% The resizing applies within the current \TeX{} group level. -% \end{function} -% -% \begin{function}[added = 2014-07-03] -% {\box_resize_to_wd_and_ht:Nnn, \box_resize_to_wd_and_ht:cnn} -% \begin{syntax} -% \cs{box_resize_to_wd_and_ht:Nnn} \meta{box} \Arg{x-size} \Arg{y-size} -% \end{syntax} -% Resize the \meta{box} to a \emph{height} of -% \meta{x-size} horizontally and \meta{y-size} -% vertically (both of the sizes are dimension expressions). -% The \meta{y-size} is the \emph{height} of the box, ignoring any depth. -% The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the resizing is applied. Negative sizes will -% cause the material in the \meta{box} to be reversed in direction, but the -% reference point of the \meta{box} will be unchanged. -% \end{function} -% -% \begin{function}{\box_rotate:Nn, \box_rotate:cn} -% \begin{syntax} -% \cs{box_rotate:Nn} \meta{box} \Arg{angle} -% \end{syntax} -% Rotates the \meta{box} by \meta{angle} (in degrees) anti-clockwise about -% its reference point. The reference point of the updated box will be moved -% horizontally such that it is at the left side of the smallest rectangle -% enclosing the rotated material. -% The updated \meta{box} will be an hbox, irrespective of the nature -% of the \meta{box} before the rotation is applied. The rotation applies -% within the current \TeX{} group level. -% \end{function} -% -% \begin{function}{\box_scale:Nnn, \box_scale:cnn} -% \begin{syntax} -% \cs{box_scale:Nnn} \meta{box} \Arg{x-scale} \Arg{y-scale} -% \end{syntax} -% Scales the \meta{box} by factors \meta{x-scale} and \meta{y-scale} in -% the horizontal and vertical directions, respectively (both scales are -% integer expressions). The updated \meta{box} will be an hbox, irrespective -% of the nature of the \meta{box} before the scaling is applied. Negative -% scalings will cause the material in the \meta{box} to be reversed in -% direction, but the reference point of the \meta{box} will be unchanged. -% Thus negative $y$-scales will result in a box a depth dependent on the -% height of the original box a height dependent on the depth. -% The resizing applies within the current \TeX{} group level. -% \end{function} -% % \subsection{Viewing part of a box} % % \begin{function}{\box_clip:N, \box_clip:c} @@ -592,6 +473,39 @@ % warning message of some sort. % \end{function} % +% \section{Additions to \pkg{l3sys}} +% +% \begin{function}[added = 2017-04-12, EXP, pTF]{\sys_if_rand_exist:} +% \begin{syntax} +% \cs{sys_if_rand_exist_p:} +% \cs{sys_if_rand_exist:TF} \Arg{true code} \Arg{false code} +% \end{syntax} +% Tests if the engine has a pseudo-random number generator. Currently +% this is the case in \pdfTeX{} and \LuaTeX{}. +% \end{function} +% +% \begin{function}[added = 2017-04-12, EXP]{\sys_rand_seed:} +% \begin{syntax} +% \cs{sys_rand_seed:} +% \end{syntax} +% Expands to the current value of the engine's random seed, a +% non-negative integer. In engines without random number support this +% expands to $0$. +% \end{function} +% +% \begin{function}[added = 2017-04-12]{\sys_gset_rand_seed:n} +% \begin{syntax} +% \cs{sys_gset_rand_seed:n} \Arg{intexpr} +% \end{syntax} +% Sets the seed for the engine's pseudo-random number generator to the +% \meta{integer expression}. The assignment is global. This random +% seed affects all \cs[no-index]{\ldots{}_rand} functions (such as +% \cs{int_rand:nn} or \cs{clist_rand_item:n}) as well as other +% packages relying on the engine's random number generator. Currently +% only the absolute value of the seed is used. In engines without +% random number support this produces an error. +% \end{function} +% % \section{Additions to \pkg{l3tl}} % % \begin{function}[EXP,pTF]{\tl_if_single_token:n} @@ -947,515 +861,6 @@ %<@@=box> % \end{macrocode} % -% \subsection{Affine transformations} -% -% \begin{variable}{\l_@@_angle_fp} -% When rotating boxes, the angle itself may be needed by the -% engine-dependent code. This is done using the \pkg{fp} module so -% that the value is tidied up properly. -% \begin{macrocode} -\fp_new:N \l_@@_angle_fp -% \end{macrocode} -% \end{variable} -% -% \begin{variable}{\l_@@_cos_fp, \l_@@_sin_fp} -% These are used to hold the calculated sine and cosine values while -% carrying out a rotation. -% \begin{macrocode} -\fp_new:N \l_@@_cos_fp -\fp_new:N \l_@@_sin_fp -% \end{macrocode} -% \end{variable} -% -% \begin{variable} -% {\l_@@_top_dim, \l_@@_bottom_dim, \l_@@_left_dim, \l_@@_right_dim} -% These are the positions of the four edges of a box before -% manipulation. -% \begin{macrocode} -\dim_new:N \l_@@_top_dim -\dim_new:N \l_@@_bottom_dim -\dim_new:N \l_@@_left_dim -\dim_new:N \l_@@_right_dim -% \end{macrocode} -% \end{variable} -% -% \begin{variable} -% { -% \l_@@_top_new_dim, \l_@@_bottom_new_dim , -% \l_@@_left_new_dim, \l_@@_right_new_dim -% } -% These are the positions of the four edges of a box after -% manipulation. -% \begin{macrocode} -\dim_new:N \l_@@_top_new_dim -\dim_new:N \l_@@_bottom_new_dim -\dim_new:N \l_@@_left_new_dim -\dim_new:N \l_@@_right_new_dim -% \end{macrocode} -% \end{variable} -% -% \begin{variable}{\l_@@_internal_box} -% Scratch space, but also needed by some parts of the driver. -% \begin{macrocode} -\box_new:N \l_@@_internal_box -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\box_rotate:Nn} -% \begin{macro}[aux]{\@@_rotate:N} -% \begin{macro}[aux]{\@@_rotate_x:nnN, \@@_rotate_y:nnN} -% \begin{macro}[aux] -% { -% \@@_rotate_quadrant_one:, \@@_rotate_quadrant_two:, -% \@@_rotate_quadrant_three:, \@@_rotate_quadrant_four: -% } -% Rotation of a box starts with working out the relevant sine and -% cosine. The actual rotation is in an auxiliary to keep the flow slightly -% clearer -% \begin{macrocode} -\cs_new_protected:Npn \box_rotate:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \fp_set:Nn \l_@@_angle_fp {#2} - \fp_set:Nn \l_@@_sin_fp { sind ( \l_@@_angle_fp ) } - \fp_set:Nn \l_@@_cos_fp { cosd ( \l_@@_angle_fp ) } - \@@_rotate:N #1 - \group_end: - } - } -% \end{macrocode} -% The edges of the box are then recorded: the left edge will -% always be at zero. Rotation of the four edges then takes place: this is -% most efficiently done on a quadrant by quadrant basis. -% \begin{macrocode} -\cs_new_protected:Npn \@@_rotate:N #1 - { - \dim_set:Nn \l_@@_top_dim { \box_ht:N #1 } - \dim_set:Nn \l_@@_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l_@@_right_dim { \box_wd:N #1 } - \dim_zero:N \l_@@_left_dim -% \end{macrocode} -% The next step is to work out the $x$ and $y$ coordinates of vertices of -% the rotated box in relation to its original coordinates. The box can be -% visualized with vertices $B$, $C$, $D$ and $E$ is illustrated -% (Figure~\ref{fig:l3candidates:rotation}). The vertex $O$ is the reference point -% on the baseline, and in this implementation is also the centre of rotation. -% \begin{figure} -% \centering -% \setlength{\unitlength}{3pt}^^A -% \begin{picture}(34,36)(12,44) -% \thicklines -% \put(20,52){\dashbox{1}(20,21){}} -% \put(20,80){\line(0,-1){36}} -% \put(12,58){\line(1, 0){34}} -% \put(41,59){A} -% \put(40,74){B} -% \put(21,74){C} -% \put(21,49){D} -% \put(40,49){E} -% \put(21,59){O} -% \end{picture} -% \caption{Co-ordinates of a box prior to rotation.} -% \label{fig:l3candidates:rotation} -% \end{figure} -% The formulae are, for a point $P$ and angle $\alpha$: -% \[ -% \begin{array}{l} -% P'_x = P_x - O_x \\ -% P'_y = P_y - O_y \\ -% P''_x = ( P'_x \cos(\alpha)) - ( P'_y \sin(\alpha) ) \\ -% P''_y = ( P'_x \sin(\alpha)) + ( P'_y \cos(\alpha) ) \\ -% P'''_x = P''_x + O_x + L_x \\ -% P'''_y = P''_y + O_y -% \end{array} -% \] -% The \enquote{extra} horizontal translation $L_x$ at the end is calculated -% so that the leftmost point of the resulting box has $x$-coordinate $0$. -% This is desirable as \TeX{} boxes must have the reference point at -% the left edge of the box. (As $O$ is always $(0,0)$, this part of the -% calculation is omitted here.) -% \begin{macrocode} - \fp_compare:nNnTF \l_@@_sin_fp > \c_zero_fp - { - \fp_compare:nNnTF \l_@@_cos_fp > \c_zero_fp - { \@@_rotate_quadrant_one: } - { \@@_rotate_quadrant_two: } - } - { - \fp_compare:nNnTF \l_@@_cos_fp < \c_zero_fp - { \@@_rotate_quadrant_three: } - { \@@_rotate_quadrant_four: } - } -% \end{macrocode} -% The position of the box edges are now known, but the box at this -% stage be misplaced relative to the current \TeX{} reference point. So the -% content of the box is moved such that the reference point of the -% rotated box will be in the same place as the original. -% \begin{macrocode} - \hbox_set:Nn \l_@@_internal_box { \box_use:N #1 } - \hbox_set:Nn \l_@@_internal_box - { - \tex_kern:D -\l_@@_left_new_dim - \hbox:n - { - \__driver_box_use_rotate:Nn - \l_@@_internal_box - \l_@@_angle_fp - } - } -% \end{macrocode} -% Tidy up the size of the box so that the material is actually inside -% the bounding box. The result can then be used to reset the original -% box. -% \begin{macrocode} - \box_set_ht:Nn \l_@@_internal_box { \l_@@_top_new_dim } - \box_set_dp:Nn \l_@@_internal_box { -\l_@@_bottom_new_dim } - \box_set_wd:Nn \l_@@_internal_box - { \l_@@_right_new_dim - \l_@@_left_new_dim } - \box_use:N \l_@@_internal_box - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% These functions take a general point $(|#1|, |#2|)$ and rotate its -% location about the origin, using the previously-set sine and cosine -% values. Each function gives only one component of the location of the -% updated point. This is because for rotation of a box each step needs -% only one value, and so performance is gained by avoiding working -% out both $x'$ and $y'$ at the same time. Contrast this with -% the equivalent function in the \pkg{l3coffins} module, where both parts -% are needed. -% \begin{macrocode} -\cs_new_protected:Npn \@@_rotate_x:nnN #1#2#3 - { - \dim_set:Nn #3 - { - \fp_to_dim:n - { - \l_@@_cos_fp * \dim_to_fp:n {#1} - - \l_@@_sin_fp * \dim_to_fp:n {#2} - } - } - } -\cs_new_protected:Npn \@@_rotate_y:nnN #1#2#3 - { - \dim_set:Nn #3 - { - \fp_to_dim:n - { - \l_@@_sin_fp * \dim_to_fp:n {#1} - + \l_@@_cos_fp * \dim_to_fp:n {#2} - } - } - } -% \end{macrocode} -% Rotation of the edges is done using a different formula for each -% quadrant. In every case, the top and bottom edges only need the -% resulting $y$-values, whereas the left and right edges need the -% $x$-values. Each case is a question of picking out which corner -% ends up at with the maximum top, bottom, left and right value. Doing -% this by hand means a lot less calculating and avoids lots of -% comparisons. -% \begin{macrocode} -\cs_new_protected:Npn \@@_rotate_quadrant_one: - { - \@@_rotate_y:nnN \l_@@_right_dim \l_@@_top_dim - \l_@@_top_new_dim - \@@_rotate_y:nnN \l_@@_left_dim \l_@@_bottom_dim - \l_@@_bottom_new_dim - \@@_rotate_x:nnN \l_@@_left_dim \l_@@_top_dim - \l_@@_left_new_dim - \@@_rotate_x:nnN \l_@@_right_dim \l_@@_bottom_dim - \l_@@_right_new_dim - } -\cs_new_protected:Npn \@@_rotate_quadrant_two: - { - \@@_rotate_y:nnN \l_@@_right_dim \l_@@_bottom_dim - \l_@@_top_new_dim - \@@_rotate_y:nnN \l_@@_left_dim \l_@@_top_dim - \l_@@_bottom_new_dim - \@@_rotate_x:nnN \l_@@_right_dim \l_@@_top_dim - \l_@@_left_new_dim - \@@_rotate_x:nnN \l_@@_left_dim \l_@@_bottom_dim - \l_@@_right_new_dim - } -\cs_new_protected:Npn \@@_rotate_quadrant_three: - { - \@@_rotate_y:nnN \l_@@_left_dim \l_@@_bottom_dim - \l_@@_top_new_dim - \@@_rotate_y:nnN \l_@@_right_dim \l_@@_top_dim - \l_@@_bottom_new_dim - \@@_rotate_x:nnN \l_@@_right_dim \l_@@_bottom_dim - \l_@@_left_new_dim - \@@_rotate_x:nnN \l_@@_left_dim \l_@@_top_dim - \l_@@_right_new_dim - } -\cs_new_protected:Npn \@@_rotate_quadrant_four: - { - \@@_rotate_y:nnN \l_@@_left_dim \l_@@_top_dim - \l_@@_top_new_dim - \@@_rotate_y:nnN \l_@@_right_dim \l_@@_bottom_dim - \l_@@_bottom_new_dim - \@@_rotate_x:nnN \l_@@_left_dim \l_@@_bottom_dim - \l_@@_left_new_dim - \@@_rotate_x:nnN \l_@@_right_dim \l_@@_top_dim - \l_@@_right_new_dim - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{variable}{\l_@@_scale_x_fp, \l_@@_scale_y_fp} -% Scaling is potentially-different in the two axes. -% \begin{macrocode} -\fp_new:N \l_@@_scale_x_fp -\fp_new:N \l_@@_scale_y_fp -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\box_resize:Nnn, \box_resize:cnn} -% \begin{macro}[aux]{\@@_resize_set_corners:N} -% \begin{macro}[aux]{\@@_resize:N} -% \begin{macro}[aux]{\@@_resize:NNN} -% Resizing a box starts by working out the various dimensions of the -% existing box. -% \begin{macrocode} -\cs_new_protected:Npn \box_resize:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \@@_resize_set_corners:N #1 -% \end{macrocode} -% The $x$-scaling and resulting box size is easy enough to work -% out: the dimension is that given as |#2|, and the scale is simply the -% new width divided by the old one. -% \begin{macrocode} - \fp_set:Nn \l_@@_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l_@@_right_dim } } -% \end{macrocode} -% The $y$-scaling needs both the height and the depth of the current box. -% \begin{macrocode} - \fp_set:Nn \l_@@_scale_y_fp - { - \dim_to_fp:n {#3} - / \dim_to_fp:n { \l_@@_top_dim - \l_@@_bottom_dim } - } -% \end{macrocode} -% Hand off to the auxiliary which does the rest of the work. -% \begin{macrocode} - \@@_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize:Nnn { c } -\cs_new_protected:Npn \@@_resize_set_corners:N #1 - { - \dim_set:Nn \l_@@_top_dim { \box_ht:N #1 } - \dim_set:Nn \l_@@_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l_@@_right_dim { \box_wd:N #1 } - \dim_zero:N \l_@@_left_dim - } -% \end{macrocode} -% With at least one real scaling to do, the next phase is to find the new -% edge co-ordinates. In the $x$~direction this is relatively easy: just -% scale the right edge. In the $y$~direction, both dimensions have to be -% scaled, and this again needs the absolute scale value. -% Once that is all done, the common resize/rescale code can be employed. -% \begin{macrocode} -\cs_new_protected:Npn \@@_resize:N #1 - { - \@@_resize:NNN \l_@@_right_new_dim - \l_@@_scale_x_fp \l_@@_right_dim - \@@_resize:NNN \l_@@_bottom_new_dim - \l_@@_scale_y_fp \l_@@_bottom_dim - \@@_resize:NNN \l_@@_top_new_dim - \l_@@_scale_y_fp \l_@@_top_dim - \@@_resize_common:N #1 - } -\cs_new_protected:Npn \@@_resize:NNN #1#2#3 - { - \dim_set:Nn #1 - { \fp_to_dim:n { \fp_abs:n { #2 } * \dim_to_fp:n { #3 } } } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\box_resize_to_ht:Nn, \box_resize_to_ht:cn} -% \begin{macro}{\box_resize_to_ht_plus_dp:Nn, \box_resize_to_ht_plus_dp:cn} -% \begin{macro}{\box_resize_to_wd:Nn, \box_resize_to_wd:cn} -% \begin{macro}{\box_resize_to_wd_and_ht:Nnn, \box_resize_to_wd_and_ht:cnn} -% Scaling to a (total) height or to a width is a simplified version of the main -% resizing operation, with the scale simply copied between the two parts. The -% internal auxiliary is called using the scaling value twice, as the sign for -% both parts is needed (as this allows the same internal code to be used as -% for the general case). -% \begin{macrocode} -\cs_new_protected:Npn \box_resize_to_ht:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \@@_resize_set_corners:N #1 - \fp_set:Nn \l_@@_scale_y_fp - { - \dim_to_fp:n {#2} - / \dim_to_fp:n { \l_@@_top_dim } - } - \fp_set_eq:NN \l_@@_scale_x_fp \l_@@_scale_y_fp - \@@_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_ht:Nn { c } -\cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \@@_resize_set_corners:N #1 - \fp_set:Nn \l_@@_scale_y_fp - { - \dim_to_fp:n {#2} - / \dim_to_fp:n { \l_@@_top_dim - \l_@@_bottom_dim } - } - \fp_set_eq:NN \l_@@_scale_x_fp \l_@@_scale_y_fp - \@@_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c } -\cs_new_protected:Npn \box_resize_to_wd:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \@@_resize_set_corners:N #1 - \fp_set:Nn \l_@@_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l_@@_right_dim } } - \fp_set_eq:NN \l_@@_scale_y_fp \l_@@_scale_x_fp - \@@_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_wd:Nn { c } -\cs_new_protected:Npn \box_resize_to_wd_and_ht:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \@@_resize_set_corners:N #1 - \fp_set:Nn \l_@@_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l_@@_right_dim } } - \fp_set:Nn \l_@@_scale_y_fp - { - \dim_to_fp:n {#3} - / \dim_to_fp:n { \l_@@_top_dim } - } - \@@_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_wd_and_ht:Nnn { c } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\box_scale:Nnn, \box_scale:cnn} -% When scaling a box, setting the scaling itself is easy enough. The -% new dimensions are also relatively easy to find, allowing only for -% the need to keep them positive in all cases. Once that is done then -% after a check for the trivial scaling a hand-off can be made to the -% common code. The dimension scaling operations are carried out using -% the \TeX{} mechanism as it avoids needing to use too many \texttt{fp} -% operations. -% \begin{macrocode} -\cs_new_protected:Npn \box_scale:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \fp_set:Nn \l_@@_scale_x_fp {#2} - \fp_set:Nn \l_@@_scale_y_fp {#3} - \dim_set:Nn \l_@@_top_dim { \box_ht:N #1 } - \dim_set:Nn \l_@@_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l_@@_right_dim { \box_wd:N #1 } - \dim_zero:N \l_@@_left_dim - \dim_set:Nn \l_@@_top_new_dim - { \fp_abs:n { \l_@@_scale_y_fp } \l_@@_top_dim } - \dim_set:Nn \l_@@_bottom_new_dim - { \fp_abs:n { \l_@@_scale_y_fp } \l_@@_bottom_dim } - \dim_set:Nn \l_@@_right_new_dim - { \fp_abs:n { \l_@@_scale_x_fp } \l_@@_right_dim } - \@@_resize_common:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_scale:Nnn { c } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[aux]{\@@_resize_common:N} -% The main resize function places in input into a box which will start -% of with zero width, and includes the handles for engine rescaling. -% \begin{macrocode} -\cs_new_protected:Npn \@@_resize_common:N #1 - { - \hbox_set:Nn \l_@@_internal_box - { - \__driver_box_use_scale:Nnn - #1 - \l_@@_scale_x_fp - \l_@@_scale_y_fp - } -% \end{macrocode} -% The new height and depth can be applied directly. -% \begin{macrocode} - \fp_compare:nNnTF \l_@@_scale_y_fp > \c_zero_fp - { - \box_set_ht:Nn \l_@@_internal_box { \l_@@_top_new_dim } - \box_set_dp:Nn \l_@@_internal_box { -\l_@@_bottom_new_dim } - } - { - \box_set_dp:Nn \l_@@_internal_box { \l_@@_top_new_dim } - \box_set_ht:Nn \l_@@_internal_box { -\l_@@_bottom_new_dim } - } -% \end{macrocode} -% Things are not quite as obvious for the width, as the reference point -% needs to remain unchanged. For positive scaling factors resizing the -% box is all that is needed. However, for case of a negative scaling -% the material must be shifted such that the reference point ends up in -% the right place. -% \begin{macrocode} - \fp_compare:nNnTF \l_@@_scale_x_fp < \c_zero_fp - { - \hbox_to_wd:nn { \l_@@_right_new_dim } - { - \tex_kern:D \l_@@_right_new_dim - \box_use:N \l_@@_internal_box - \tex_hss:D - } - } - { - \box_set_wd:Nn \l_@@_internal_box { \l_@@_right_new_dim } - \hbox:n - { - \tex_kern:D \c_zero_dim - \box_use:N \l_@@_internal_box - \tex_hss:D - } - } - } -% \end{macrocode} -% \end{macro} -% % \subsection{Viewing part of a box} % % \begin{macro}{\box_clip:N, \box_clip:c} @@ -1960,7 +1365,7 @@ \dim_to_fp:n {#3} / \dim_to_fp:n { \coffin_ht:N #1 + \coffin_dp:N #1 } } - \box_resize:Nnn #1 {#2} {#3} + \box_resize_to_wd_and_ht_plus_dp:Nnn #1 {#2} {#3} \@@_resize_common:Nnn #1 {#2} {#3} } \cs_generate_variant:Nn \coffin_resize:Nnn { c } @@ -2142,8 +1547,8 @@ % Mapping to an input stream can be done on either a token or a string % basis, hence the set up. Within that, there is a check to avoid reading % past the end of a file, hence the two applications of \cs{ior_if_eof:N}. -% This mapping cannot be nested as the stream has only one \enquote{current -% line}. +% This mapping cannot be nested with twice the same stream, as the +% stream has only one \enquote{current line}. % \begin{macrocode} \cs_new_protected:Npn \ior_map_inline:Nn { \@@_map_inline:NNn \ior_get:NN } @@ -2157,7 +1562,7 @@ } \cs_new_protected:Npn \@@_map_inline:NNNn #1#2#3#4 { - \cs_set:Npn #1 ##1 {#4} + \cs_gset_protected:Npn #1 ##1 {#4} \ior_if_eof:NF #3 { \@@_map_inline_loop:NNN #1#2#3 } \__prg_break_point:Nn \ior_map_break: { \int_gdecr:N \g__prg_map_int } @@ -2567,9 +1972,41 @@ } } % \end{macrocode} -% \end{macro} +% \end{macro} +% +% \subsection{Additions to \pkg{l3sys}} +% +% \begin{macro}[EXP, pTF]{\sys_if_rand_exist:} +% Currently, randomness exists under \pdfTeX{} and \LuaTeX{}. +% \begin{macrocode} +\cs_if_exist:NTF \pdftex_uniformdeviate:D + { + \prg_new_conditional:Npnn \sys_if_rand_exist: { p , T , F , TF } + { \prg_return_true: } + } + { + \prg_new_conditional:Npnn \sys_if_rand_exist: { p , T , F , TF } + { \prg_return_false: } + } +% \end{macrocode} +% \end{macro} % -% \subsection{Additions to \pkg{l3tl}} +% \begin{macro}[EXP]{\sys_rand_seed:} +% Unpack the primitive. +% \begin{macrocode} +\cs_new:Npn \sys_rand_seed: { \tex_the:D \pdftex_randomseed:D } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sys_gset_rand_seed:n} +% The primitive always assigns the seed globally. +% \begin{macrocode} +\cs_new_protected:Npn \sys_gset_rand_seed:n #1 + { \pdftex_setrandomseed:D \__int_eval:w #1 \__int_eval_end: } +% \end{macrocode} +% \end{macro} +% +% \subsection{Additions to \pkg{l3tl}} % % \begin{macrocode} %<@@=tl> @@ -3697,10 +3134,9 @@ % octets, so that is taken as read. % \begin{macrocode} \group_begin: - \bool_if:nT - { - \sys_if_engine_pdftex_p: || \sys_if_engine_uptex_p: - } + \bool_lazy_or:nnT + { \sys_if_engine_pdftex_p: } + { \sys_if_engine_uptex_p: } { \cs_set_protected:Npn \@@_loop:nn #1#2 { |