[latex3-commits] [git/LaTeX3-latex3-latex3] master: Re-arrange color pickup code (15600aecd)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Dec 8 15:08:22 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/15600aecd9fa9bc60ec93a21b17d25580a15f876

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

commit 15600aecd9fa9bc60ec93a21b17d25580a15f876
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Dec 8 14:08:22 2020 +0000

    Re-arrange color pickup code
    
    As we will need further changes to other parts.


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

15600aecd9fa9bc60ec93a21b17d25580a15f876
 l3backend/l3backend-color.dtx           | 186 +++++++++++++++++---------------
 l3kernel/testfiles/m3expl001.luatex.tlg |   2 +-
 l3kernel/testfiles/m3expl001.tlg        |   2 +-
 l3kernel/testfiles/m3expl003.luatex.tlg |   2 +-
 l3kernel/testfiles/m3expl003.tlg        |   2 +-
 5 files changed, 104 insertions(+), 90 deletions(-)

diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index fbb494326..ff0e3fd10 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -60,13 +60,112 @@
 %<@@=color>
 %    \end{macrocode}
 %
-% Color support is split into parts: the color stack, general color, separations, and color for
+% Color support is split into parts: collecting data from \LaTeXe{}, the color stack, general color, separations, and color for
 % drawings. We have different approaches in each backend, and have some choices
 % to make about \texttt{dvipdfmx}/\XeTeX{} in particular. Whilst it is in some ways
 % convenient to use the same approach in multiple backends, the fact that
 % \texttt{dvipdfmx}/\XeTeX{} is PDF-based means it (largely) sticks closer to
 % direct PDF output.
 %
+% \subsection{Collecting information from \LaTeXe{}}
+%
+% \subsubsection{\texttt{dvips}-style}
+%
+%    \begin{macrocode}
+%<*dvisvgm|dvipdfmx|dvips|xetex>
+%    \end{macrocode}
+%
+% \begin{macro}{\@@_backend_pickup:N}
+% \begin{macro}{\@@_backend_pickup:w}
+%   Allow for \LaTeXe{} color. Here, the possible input values are limited:
+%   \texttt{dvips}-style colors can mainly be taken as-is with the exception
+%   spot ones (here we need a model and a tint). The \texttt{x}-type expansion
+%   is there to cover the case where \pkg{xcolor} is in use.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_pickup:N #1 { }
+\cs_if_exist:cT { ver at color.sty }
+  {
+    \cs_set_protected:Npn \@@_backend_pickup:N #1
+      {
+        \exp_args:NV \tl_if_head_is_space:nTF \current at color
+          {
+            \tl_set:Nx #1
+               {
+                 { \exp_after:wN \use:n \current at color }
+                 { 1 }
+               }
+          }
+          {
+            \exp_last_unbraced:Nx \@@_backend_pickup:w
+              { \current at color } \s_@@_stop #1
+          }
+      }
+    \cs_new_protected:Npn \@@_backend_pickup:w #1 ~ #2 \s_@@_stop #3
+      { \tl_set:Nn #3 { {#1} {#2} } }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%    \begin{macrocode}
+%</dvisvgm|dvipdfmx|dvips|xetex>
+%    \end{macrocode}
+%
+% \subsubsection{\LuaTeX{} and \pdfTeX{}}
+%
+%    \begin{macrocode}
+%<*luatex|pdftex>
+%    \end{macrocode}
+%
+% \begin{macro}{\@@_backend_pickup:N}
+% \begin{macro}{\@@_backend_pickup:w}
+%   The current color in driver-dependent format: pick up the package-mode
+%   data if available. We end up converting back and forward in this route as
+%   we store our color data in \texttt{dvips} format.
+%   The \tn{current at color} needs to be \texttt{x}-expanded before
+%   \cs{@@_backend_pickup:w} breaks it apart, because for instance
+%   \pkg{xcolor} sets it to be instructions to generate a color
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_pickup:N #1 { }
+\cs_if_exist:cT { ver at color.sty }
+  {
+    \cs_set_protected:Npn \@@_backend_pickup:N #1
+      {
+        \exp_last_unbraced:Nx \@@_backend_pickup:w
+          { \current at color } ~ 0 ~ 0 ~ 0 \s_@@_stop #1
+      }
+    \cs_new_protected:Npn \@@_backend_pickup:w
+      #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \s_@@_stop #7
+      {
+        \str_if_eq:nnTF {#2} { g }
+          { \tl_set:Nn #7 { { gray } {#1} } }
+          {
+            \str_if_eq:nnTF {#4} { rg }
+              { \tl_set:Nn #7 { { rgb } { #1 ~ #2 ~ #3 } } }
+              {
+                 \str_if_eq:nnTF {#5} { k }
+                   { \tl_set:Nn #7 { { cmyk } { #1 ~ #2 ~ #3 ~ #4 } } }
+                   {
+                     \str_if_eq:nnTF {#2} { cs }
+                       {
+                         \tl_set:Nx #7 { { \use:n #1 } { #5 } }
+                       }
+                       {
+                         \tl_set:Nn #7 { { gray } { 0 } }
+                       }
+                   }
+              }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%    \begin{macrocode}
+%</luatex|pdftex>
+%    \end{macrocode}
+%
 % \subsection{The color stack}
 %
 % For PDF-based engines, we have a color stack available inside the specials.
@@ -172,46 +271,6 @@
 % \subsubsection{\texttt{dvips}-style}
 %
 %    \begin{macrocode}
-%<*dvisvgm|dvipdfmx|dvips|xetex>
-%    \end{macrocode}
-%
-% \begin{macro}{\@@_backend_pickup:N}
-% \begin{macro}{\@@_backend_pickup:w}
-%   Allow for \LaTeXe{} color. Here, the possible input values are limited:
-%   \texttt{dvips}-style colors can mainly be taken as-is with the exception
-%   spot ones (here we need a model and a tint). The \texttt{x}-type expansion
-%   is there to cover the case where \pkg{xcolor} is in use.
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_pickup:N #1 { }
-\cs_if_exist:cT { ver at color.sty }
-  {
-    \cs_set_protected:Npn \@@_backend_pickup:N #1
-      {
-        \exp_args:NV \tl_if_head_is_space:nTF \current at color
-          {
-            \tl_set:Nx #1
-               {
-                 { \exp_after:wN \use:n \current at color }
-                 { 1 }
-               }
-          }
-          {
-            \exp_last_unbraced:Nx \@@_backend_pickup:w
-              { \current at color } \s_@@_stop #1
-          }
-      }
-    \cs_new_protected:Npn \@@_backend_pickup:w #1 ~ #2 \s_@@_stop #3
-      { \tl_set:Nn #3 { {#1} {#2} } }
-  }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-%    \begin{macrocode}
-%</dvisvgm|dvipdfmx|dvips|xetex>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
 %<*dvips|dvisvgm>
 %    \end{macrocode}
 %
@@ -259,51 +318,6 @@
 %<*luatex|pdftex>
 %    \end{macrocode}
 %
-% \begin{macro}{\@@_backend_pickup:N}
-% \begin{macro}{\@@_backend_pickup:w}
-%   The current color in driver-dependent format: pick up the package-mode
-%   data if available. We end up converting back and forward in this route as
-%   we store our color data in \texttt{dvips} format.
-%   The \tn{current at color} needs to be \texttt{x}-expanded before
-%   \cs{@@_backend_pickup:w} breaks it apart, because for instance
-%   \pkg{xcolor} sets it to be instructions to generate a color
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_pickup:N #1 { }
-\cs_if_exist:cT { ver at color.sty }
-  {
-    \cs_set_protected:Npn \@@_backend_pickup:N #1
-      {
-        \exp_last_unbraced:Nx \@@_backend_pickup:w
-          { \current at color } ~ 0 ~ 0 ~ 0 \s_@@_stop #1
-      }
-    \cs_new_protected:Npn \@@_backend_pickup:w
-      #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \s_@@_stop #7
-      {
-        \str_if_eq:nnTF {#2} { g }
-          { \tl_set:Nn #7 { { gray } {#1} } }
-          {
-            \str_if_eq:nnTF {#4} { rg }
-              { \tl_set:Nn #7 { { rgb } { #1 ~ #2 ~ #3 } } }
-              {
-                 \str_if_eq:nnTF {#5} { k }
-                   { \tl_set:Nn #7 { { cmyk } { #1 ~ #2 ~ #3 ~ #4 } } }
-                   {
-                     \str_if_eq:nnTF {#2} { cs }
-                       {
-                         \tl_set:Nx #7 { { \use:n #1 } { #5 } }
-                       }
-                       {
-                         \tl_set:Nn #7 { { gray } { 0 } }
-                       }
-                   }
-              }
-          }
-      }
-  }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
 % \begin{variable}{\l__kernel_color_stack_int}
 %   \pdfTeX{} and \LuaTeX{} have multiple stacks available, and to track
 %   which one is in use a variable is required.
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 2bd13fb11..071059cb7 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -27,9 +27,9 @@ Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__kernel_backend_matrix:n on line ...
 Defining \__kernel_backend_matrix:x on line ...
+Defining \__color_backend_pickup:N on line ...
 Defining \__kernel_color_stack_push:nn on line ...
 Defining \__kernel_color_stack_pop:n on line ...
-Defining \__color_backend_pickup:N on line ...
 Defining \l__kernel_color_stack_int on line ...
 \l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 77d914451..5053f1818 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -27,9 +27,9 @@ Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__kernel_backend_matrix:n on line ...
 Defining \__kernel_backend_matrix:x on line ...
+Defining \__color_backend_pickup:N on line ...
 Defining \__kernel_color_stack_push:nn on line ...
 Defining \__kernel_color_stack_pop:n on line ...
-Defining \__color_backend_pickup:N on line ...
 Defining \l__kernel_color_stack_int on line ...
 \l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 2bd13fb11..071059cb7 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -27,9 +27,9 @@ Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__kernel_backend_matrix:n on line ...
 Defining \__kernel_backend_matrix:x on line ...
+Defining \__color_backend_pickup:N on line ...
 Defining \__kernel_color_stack_push:nn on line ...
 Defining \__kernel_color_stack_pop:n on line ...
-Defining \__color_backend_pickup:N on line ...
 Defining \l__kernel_color_stack_int on line ...
 \l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 77d914451..5053f1818 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -27,9 +27,9 @@ Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__kernel_backend_matrix:n on line ...
 Defining \__kernel_backend_matrix:x on line ...
+Defining \__color_backend_pickup:N on line ...
 Defining \__kernel_color_stack_push:nn on line ...
 Defining \__kernel_color_stack_pop:n on line ...
-Defining \__color_backend_pickup:N on line ...
 Defining \l__kernel_color_stack_int on line ...
 \l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...





More information about the latex3-commits mailing list.