[latex3-commits] [git/LaTeX3-latex3-latex3] master: Re-introduce draw support for coffins (22f5412)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Mar 4 21:11:21 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/22f5412d8402915a91d6688c4296a073d6f6fe9d
>---------------------------------------------------------------
commit 22f5412d8402915a91d6688c4296a073d6f6fe9d
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Sun Mar 4 20:11:21 2018 +0000
Re-introduce draw support for coffins
This time actually dealing with the bounding box correctly (at least for non-rotated coffins).
Question: do we want to support coffins rotated at the
'standard' level, or should this be left to drawing matrix work?
>---------------------------------------------------------------
22f5412d8402915a91d6688c4296a073d6f6fe9d
l3experimental/l3draw/l3draw-boxes.dtx | 36 +++++++++++++++++++++++++++-----
l3experimental/l3draw/l3draw.dtx | 22 +++++++++++++++++++
2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/l3experimental/l3draw/l3draw-boxes.dtx b/l3experimental/l3draw/l3draw-boxes.dtx
index 8f30456..bef1c1c 100644
--- a/l3experimental/l3draw/l3draw-boxes.dtx
+++ b/l3experimental/l3draw/l3draw-boxes.dtx
@@ -69,27 +69,33 @@
% \end{variable}
%
% \begin{macro}{\draw_box_use:N}
+% \begin{macro}{\@@_box_use:Nnnnn}
% Before inserting a box, we need to make sure that the bounding box is being
% updated correctly. As drawings track transformations as a whole, rather
% than as separate operations, we do the insertion using an almost-raw
-% matrix.
+% matrix. The process is split into two so that coffins are also supported.
% \begin{macrocode}
\cs_new_protected:Npn \draw_box_use:N #1
{
+ \@@_box_use:Nnnnn #1
+ { 0pt } { -\box_dp:N #1 } { \box_wd:N #1 } { \box_ht:N #1 }
+ }
+\cs_new_protected:Npn \@@_box_use:Nnnnn #1#2#3#4#5
+ {
\bool_if:NT \l_draw_bb_update_bool
{
\@@_point_process:nn
{ \@@_path_update_limits:nn }
- { \draw_point_transform:n { 0pt , \box_dp:N #1 } }
+ { \draw_point_transform:n { #2 , #3 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
- { \draw_point_transform:n { \box_wd:N #1 , \box_dp:N #1 } }
+ { \draw_point_transform:n { #4 , #3 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
- { \draw_point_transform:n { 0pt , \box_ht:N #1 } }
+ { \draw_point_transform:n { #4 , #5 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
- { \draw_point_transform:n { \box_wd:N #1 , \box_ht:N #1 } }
+ { \draw_point_transform:n { #2 , #5 } }
}
\group_begin:
\hbox_set:Nn \l_@@_tmp_box
@@ -117,6 +123,26 @@
}
% \end{macrocode}
% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\draw_coffin_use:Nnn}
+% Slightly more than a shortcut: we have to allow for the fact that coffins
+% have no apparent width before the reference point.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_coffin_use:Nnn #1#2#3
+ {
+ \group_begin:
+ \hbox_set:Nn \l_@@_tmp_box
+ { \coffin_typeset:Nnnnn #1 {#2} {#3} { 0pt } { 0pt } }
+ \@@_box_use:Nnnnn \l_@@_tmp_box
+ { \box_wd:N \l_@@_tmp_box - \coffin_wd:N #1 }
+ { -\box_dp:N \l_@@_tmp_box }
+ { \box_wd:N \l_@@_tmp_box }
+ { \box_ht:N \l_@@_tmp_box }
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
%</initex|package>
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index 1beeb93..f367e4d 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -933,6 +933,28 @@
% \end{demo}
% \end{function}
%
+% \begin{function}{\draw_coffin_use:Nnn}
+% \begin{syntax}
+% \cs{draw_coffin_use:N} \meta{coffin} \Arg{hpole} \Arg{vpole}
+% \end{syntax}
+% Inserts the \meta{coffin} into a drawing, taking account of the current
+% transformation matrix and shift, and adjusting the drawing bounding
+% box to contain the (apparent) size of the box if this is active
+% (see \cs{l_draw_bb_update_bool}). The alignment point of the coffin to
+% the origin is specified by the intersection of the \meta{hpole} and the
+% \meta{vpole}.
+% \begin{demo}
+% \draw_begin:
+% \draw_path_moveto:n { 0cm , 0cm }
+% \draw_path_lineto:n { 0cm , 1cm }
+% \draw_path_use_clear:n { stroke }
+% \hcoffin_set:Nn \l_tmpa_coffin
+% { This~is~text. }
+% \draw_coffin_use:Nnn \l_tmpa_coffin { hc } { vc }
+% \draw_end:
+% \end{demo}
+% \end{function}
+%
% \subsection{Color}
%
% \begin{function}{\draw_color:n, \draw_color_fill:n, \draw_color_stroke:n}
More information about the latex3-commits
mailing list