[latex3-commits] [git/LaTeX3-latex3-latex2e] picture-lengths: first draft of default unit code in picture mode (9f2a2e0a)

David Carlisle d.p.carlisle at gmail.com
Fri Aug 14 23:17:10 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : picture-lengths
Link       : https://github.com/latex3/latex2e/commit/9f2a2e0a90294633fe504477015f8d698994ab38

>---------------------------------------------------------------

commit 9f2a2e0a90294633fe504477015f8d698994ab38
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Fri Aug 14 22:17:10 2020 +0100

    first draft of default unit code in picture mode


>---------------------------------------------------------------

9f2a2e0a90294633fe504477015f8d698994ab38
 base/ltpictur.dtx | 103 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 65 insertions(+), 38 deletions(-)

diff --git a/base/ltpictur.dtx b/base/ltpictur.dtx
index 8cc4c344..e7cfd3b5 100644
--- a/base/ltpictur.dtx
+++ b/base/ltpictur.dtx
@@ -32,7 +32,7 @@
 %<*driver>
 % \fi
       \ProvidesFile{ltpictur.dtx}
-                      [2020/07/27 v1.1p LaTeX Kernel (Picture Mode)]
+                      [2020/08/14 v1.2a LaTeX Kernel (Picture Mode)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltpictur.dtx}
@@ -191,6 +191,12 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\setlengthdefaultunit}
+%    \begin{macrocode}
+\def\setlengthdefaultunit#1#2#3{\@defaultunits#1\dimexpr#2#3\relax\relax\@nnil}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{environment}{picture}
 % \begin{macro}{\picture}
 % \changes{v0.1c}{1994/04/28}{(DPC) Ignore spaces before (}
@@ -209,10 +215,13 @@
 % \begin{macro}{\@picture}
 %    \begin{macrocode}
 \def\@picture(#1,#2)(#3,#4){%
-  \@picht#2\unitlength
-  \setbox\@picbox\hb at xt@#1\unitlength\bgroup
-    \hskip -#3\unitlength
-    \lower #4\unitlength\hbox\bgroup
+  \setlengthdefaultunit\@picht{#2}\unitlength
+  \setlengthdefaultunit\@tempdimc{#1}\unitlength
+  \setbox\@picbox\hb at xt@\@tempdimc\bgroup
+    \setlengthdefaultunit\@tempdimc{#3}\unitlength
+    \hskip -\@tempdimc
+    \setlengthdefaultunit\@tempdimc{#4}\unitlength
+    \lower\@tempdimc\hbox\bgroup
       \ignorespaces}
 %    \end{macrocode}
 % \end{macro}
@@ -238,8 +247,13 @@
 %
 %    \begin{macrocode}
 \long\def\put(#1,#2)#3{%
-  \@killglue\raise#2\unitlength
-  \hb at xt@\z@{\kern#1\unitlength #3\hss}%
+  \@killglue
+  \setlengthdefaultunit\@tempdimc{#2}\unitlength
+  \raise\@tempdimc
+  \hb at xt@\z@{%
+    \setlengthdefaultunit\@tempdimc{#1}\unitlength
+    \kern\@tempdimc
+    #3\hss}%
   \ignorespaces}
 %    \end{macrocode}
 %
@@ -249,8 +263,8 @@
 % |#3| had better be a |(|.
 %    \begin{macrocode}
 \def\multiput(#1,#2)#3{%
-  \@xdim #1\unitlength
-  \@ydim #2\unitlength
+  \setlengthdefaultunit\@xdim{#1}\unitlength
+  \setlengthdefaultunit\@ydim{#2}\unitlength
    \@multiput(}
 %    \end{macrocode}
 % \end{macro}
@@ -263,7 +277,8 @@
   \@whilenum \@multicnt >\z@\do
     {\raise\@ydim\hb at xt@\z@{\kern\@xdim #4\hss}%
      \advance\@multicnt\m at ne
-     \advance\@xdim#1\unitlength\advance\@ydim#2\unitlength}%
+     \setlengthdefaultunit{\advance\@xdim}{#1}\unitlength
+     \setlengthdefaultunit{\advance\@ydim}{#2}\unitlength}%
   \ignorespaces}
 %    \end{macrocode}
 % \end{macro}
@@ -533,7 +548,7 @@
 % \begin{macro}{\line}
 %    \begin{macrocode}
 \def\line(#1,#2)#3{\@xarg #1\relax \@yarg #2\relax
-  \@linelen #3\unitlength
+  \setlengthdefaultunit\@linelen{#3}\unitlength
   \ifdim\@linelen<\z@\@badlinearg\else
     \ifnum\@xarg =\z@ \@vline
       \else \ifnum\@yarg =\z@ \@hline \else \@sline\fi
@@ -625,7 +640,7 @@
 \def\vector(#1,#2)#3{\@xarg #1\relax \@yarg #2\relax
   \@tempcnta \ifnum\@xarg<\z@ -\@xarg\else\@xarg\fi
   \ifnum\@tempcnta<5\relax
-  \@linelen #3\unitlength
+  \setlengthdefaultunit\@linelen{#3}\unitlength
   \ifdim\@linelen<\z@\@badlinearg\else
     \ifnum\@xarg =\z@ \@vvector
       \else \ifnum\@yarg =\z@ \@hvector \else \@svector\fi
@@ -827,9 +842,10 @@
 %    \begin{macrocode}
 \def\dashbox#1(#2,#3){\leavevmode\hb at xt@\z@{\baselineskip \z at skip
 \lineskip \z at skip
-\@dashdim #2\unitlength
+\setlengthdefaultunit\@dashdim{#2}\unitlength
 \@dashcnt \@dashdim \advance\@dashcnt 200
-\@dashdim #1\unitlength\divide\@dashcnt \@dashdim
+\setlengthdefaultunit\@dashdim{#1}\unitlength
+\divide\@dashcnt \@dashdim
 \ifodd\@dashcnt\@dashdim \z@
 \advance\@dashcnt \@ne \divide\@dashcnt \tw@
 \else \divide\@dashdim \tw@ \divide\@dashcnt \tw@
@@ -841,15 +857,19 @@
 \put(#2,#3){\hskip-\@dashdim\box\@dashbox}%
 \multiply\@dashdim \thr@@
 \fi
-\setbox\@dashbox \hbox{\vrule \@height \@halfwidth \@depth \@halfwidth
-\@width #1\unitlength\hskip #1\unitlength}\@tempcnta\z@
+\setbox\@dashbox \hbox{%
+  \setlengthdefaultunit\@tempdimc{#1}\unitlength
+  \vrule \@height \@halfwidth \@depth \@halfwidth \@width \@tempdimc
+  \hskip\@tempdimc}%
+\@tempcnta\z@
 \put(0,0){\hskip\@dashdim \@whilenum \@tempcnta <\@dashcnt
 \do{\copy\@dashbox\advance\@tempcnta \@ne }}\@tempcnta\z@
 \put(0,#3){\hskip\@dashdim \@whilenum \@tempcnta <\@dashcnt
 \do{\copy\@dashbox\advance\@tempcnta \@ne }}%
-\@dashdim #3\unitlength
+\setlengthdefaultunit\@dashdim{#3}\unitlength
 \@dashcnt \@dashdim \advance\@dashcnt 200
-\@dashdim #1\unitlength\divide\@dashcnt \@dashdim
+\setlengthdefaultunit\@dashdim{#1}\unitlength
+\divide\@dashcnt \@dashdim
 \ifodd\@dashcnt \@dashdim \z@
 \advance\@dashcnt \@ne \divide\@dashcnt \tw@
 \else
@@ -863,13 +883,15 @@
 \put(#2,#3){\lower\@dashdim\copy\@dashbox}%
 \multiply\@dashdim \thr@@
 \fi
-\setbox\@dashbox\hbox{\vrule \@width \@wholewidth
-\@height #1\unitlength}\@tempcnta\z@
+\setbox\@dashbox\hbox{%
+  \setlengthdefaultunit\@tempdimc{#1}\unitlength
+  \vrule \@width \@wholewidth \@height\@tempdimc}%
+\@tempcnta\z@
 \put(0,0){\hskip -\@halfwidth \vbox{\@whilenum \@tempcnta <\@dashcnt
-\do{\vskip #1\unitlength\copy\@dashbox\advance\@tempcnta \@ne }%
+\do{\vskip\@height\copy\@dashbox\advance\@tempcnta \@ne }%
 \vskip\@dashdim}}\@tempcnta\z@
 \put(#2,0){\hskip -\@halfwidth \vbox{\@whilenum \@tempcnta<\@dashcnt
-\do{\vskip #1\unitlength\copy\@dashbox\advance\@tempcnta \@ne }%
+\do{\vskip\@height\copy\@dashbox\advance\@tempcnta \@ne }%
 \vskip\@dashdim}}}\@makepicbox(#2,#3)}
 %    \end{macrocode}
 % \end{macro}
@@ -1180,8 +1202,8 @@
 %    \end{macrocode}
 %    \begin{macrocode}
   \@tfor\reserved at a :=#3\do{\csname @ov\reserved at a false\endcsname}%
-  \@ovxx #1\unitlength
-  \@ovyy #2\unitlength
+  \setlengthdefaultunit\@ovxx{#1}\unitlength
+  \setlengthdefaultunit\@ovyy{#2}\unitlength
 %    \end{macrocode}
 % \changes{v1.1l}{2016/03/29}{add setting of line tests}
 %    \begin{macrocode}
@@ -1307,7 +1329,8 @@
 % \begin{macro}{\@circle}
 %    \begin{macrocode}
 \def\@circle#1{%
-  \begingroup \boxmaxdepth \maxdimen \@tempdimb #1\unitlength
+  \begingroup \boxmaxdepth \maxdimen
+   \setlengthdefaultunit\@tempdimb{#1}\unitlength
    \ifdim \@tempdimb >15.5\p@ \@getcirc\@tempdimb
       \@ovro\ht\@tempboxa
      \setbox\@tempboxa\hbox{\@circlefnt
@@ -1324,7 +1347,7 @@
 % \begin{macro}{\@dot}
 % Internal form of |\circle*|.
 %    \begin{macrocode}
-\def\@dot#1{\@tempdimb #1\unitlength \@circ\@tempdimb{112}}
+\def\@dot#1{\setlengthdefaultunit\@tempdimb{#1}\unitlength \@circ\@tempdimb{112}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1506,18 +1529,18 @@
 %    \begin{macrocode}
 \def\@bezier#1(#2,#3)(#4,#5)(#6,#7){%
   \ifnum #1=\z@
-      \@ovxx #4\unitlength
-        \advance\@ovxx -#2\unitlength
+      \setlengthdefaultunit\@ovxx{#4}\unitlength
+        \setlengthdefaultunit{\advance\@ovxx}{-#2}\unitlength
         \ifdim \@ovxx<\z@ \@ovxx -\@ovxx \fi
-      \@ovdx #6\unitlength
-        \advance\@ovdx -#4\unitlength
+      \setlengthdefaultunit\@ovdx{#6}\unitlength
+        \setlengthdefaultunit{\advance\@ovdx}{-#4}\unitlength
         \ifdim \@ovdx<\z@ \@ovdx -\@ovdx \fi
         \ifdim \@ovxx<\@ovdx \@ovxx \@ovdx \fi
-      \@ovyy #5\unitlength
-        \advance\@ovyy -#3\unitlength
+      \setlengthdefaultunit\@ovyy{#5}\unitlength
+        \setlengthdefaultunit{\advance\@ovyy}{-#3}\unitlength
         \ifdim \@ovyy<\z@ \@ovyy -\@ovyy \fi
-      \@ovdy #7\unitlength
-        \advance\@ovdy -#5\unitlength
+      \setlengthdefaultunit\@ovdy{#7}\unitlength
+        \setlengthdefaultunit{\advance\@ovdy}{-#5}\unitlength
         \ifdim \@ovdy<\z@  \@ovdy -\@ovdy \fi
         \ifdim \@ovyy<\@ovdy \@ovyy  \@ovdy \fi
       \@multicnt
@@ -1526,13 +1549,17 @@
       \ifnum \qbeziermax<\@multicnt \@multicnt\qbeziermax\relax \fi
   \else \@multicnt#1\relax \fi
   \@tempcnta\@multicnt \advance\@tempcnta\@ne
-  \@ovdx #4\unitlength \advance\@ovdx -#2\unitlength
+  \setlengthdefaultunit\@ovdx{#4}\unitlength
+  \setlengthdefaultunit{\advance\@ovdx}{-#2}\unitlength
       \multiply\@ovdx \tw@
-  \@ovxx #6\unitlength \advance\@ovxx -#2\unitlength
+  \setlengthdefaultunit\@ovxx{#6}\unitlength
+  \setlengthdefaultunit{\advance\@ovxx}{-#2}\unitlength
       \advance\@ovxx -\@ovdx \divide\@ovxx\@multicnt
-  \@ovdy #5\unitlength \advance\@ovdy -#3\unitlength
+  \setlengthdefaultunit\@ovdy{#5}\unitlength
+  \setlengthdefaultunit{\advance\@ovdy}{-#3}\unitlength
        \multiply\@ovdy \tw@
-  \@ovyy #7\unitlength \advance\@ovyy -#3\unitlength
+  \setlengthdefaultunit\@ovyy{#7}\unitlength
+  \setlengthdefaultunit{\advance\@ovyy}{-#3}\unitlength
       \advance\@ovyy -\@ovdy \divide\@ovyy\@multicnt
 %    \end{macrocode}
 %





More information about the latex3-commits mailing list.