[latex3-commits] [git/LaTeX3-latex3-latex3] current-color: Define color 'pickup' in all cases (b945c6998)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Aug 11 15:11:25 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : current-color
Link       : https://github.com/latex3/latex3/commit/b945c6998d21b49449b3343356760addb04be4f7

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

commit b945c6998d21b49449b3343356760addb04be4f7
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Aug 11 14:11:25 2022 +0100

    Define color 'pickup' in all cases
    
    Formally this may need to be made public if
    we decide against (re)defining \set at color ourselves.


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

b945c6998d21b49449b3343356760addb04be4f7
 l3backend/CHANGELOG.md                  |  3 ++
 l3backend/l3backend-color.dtx           | 80 +++++++++++++--------------------
 l3kernel/CHANGELOG.md                   |  2 +
 l3kernel/l3color.dtx                    | 12 ++---
 l3kernel/testfiles/m3expl001.luatex.tlg |  1 +
 l3kernel/testfiles/m3expl001.ptex.tlg   |  1 +
 l3kernel/testfiles/m3expl001.tlg        |  1 +
 l3kernel/testfiles/m3expl001.uptex.tlg  |  1 +
 l3kernel/testfiles/m3expl001.xetex.tlg  |  1 +
 l3kernel/testfiles/m3expl003.luatex.tlg |  1 +
 l3kernel/testfiles/m3expl003.ptex.tlg   |  1 +
 l3kernel/testfiles/m3expl003.tlg        |  1 +
 l3kernel/testfiles/m3expl003.uptex.tlg  |  1 +
 l3kernel/testfiles/m3expl003.xetex.tlg  |  1 +
 14 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/l3backend/CHANGELOG.md b/l3backend/CHANGELOG.md
index 3c8cb7d6d..ee5dca934 100644
--- a/l3backend/CHANGELOG.md
+++ b/l3backend/CHANGELOG.md
@@ -6,6 +6,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+- Approach to setting current color data from LaTeX2e
+
 ## [2022-08-05]
 
 ### Changed
diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index 336ff4513..1f13f02f0 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -79,31 +79,24 @@
 % \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
+%   \texttt{dvips}-style colors can be taken as-is. 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_new_protected:Npn \@@_backend_pickup:N #1
   {
-    \cs_set_protected:Npn \@@_backend_pickup:N #1
+    \exp_args:NV \tl_if_head_is_space:nTF \current at color
       {
-        \exp_args:NV \tl_if_head_is_space:nTF \current at color
-          {
-            \tl_set:Nx #1
-               {
-                 { named }
-                 { \exp_after:wN \use:n \current at color }
-               }
-          }
-          {
-            \exp_last_unbraced:Nx \@@_backend_pickup:w
-              { \current at color } \s_@@_stop #1
-          }
+        \tl_set:Nn #1 { { gray } { 0 } }
+        \msg_warning:nnx { color } { unhandled }
+          { \current at color }
+      }
+      {
+        \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} } }
   }
+\cs_new_protected:Npn \@@_backend_pickup:w #1 ~ #2 \s_@@_stop #3
+  { \tl_set:Nn #3 { {#1} {#2} } }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -120,41 +113,28 @@
 %
 % \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 }
+%  Same ideas, but with a different backend-dependent format.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_pickup:N #1
   {
-    \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
+    \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 {#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 {#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 {#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 } }
-                       }
-                   }
+                \tl_set:Nn #1 { { gray } { 0 } }
+                \msg_warning:nnx { color } { unhandled }
+                  { \current at color }
               }
           }
       }
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 4375c9ebb..2fc268cbe 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -10,6 +10,8 @@ this project uses date-based 'snapshot' version identifiers.
 ### Added
 - Support for case changing Vietnamese characters with 8-bit engines
 
+### Changed
+- Approach to setting current color data from LaTeX2e
 ## [2022-08-05]
 
 ### Added
diff --git a/l3kernel/l3color.dtx b/l3kernel/l3color.dtx
index 8fc7268cd..5db88b96f 100644
--- a/l3kernel/l3color.dtx
+++ b/l3kernel/l3color.dtx
@@ -545,10 +545,7 @@
 %   current color \enquote{now}.
 %    \begin{macrocode}
 \cs_new_protected:Npn \color_ensure_current:
-  {
-    \@@_backend_pickup:N \l_@@_current_tl
-    \@@_select:N \l_@@_current_tl
-  }
+  { \@@_select:N \l_@@_current_tl }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -811,7 +808,6 @@
 %    \begin{macrocode}
 \cs_new_protected:Npx \@@_parse:nN #1#2
   {
-    \exp_not:N \@@_backend_pickup:N \exp_not:N \l_@@_current_tl
     \tl_set:Nx \exp_not:c { l_@@_named_ . _tl }
       { \exp_not:N \@@_model:N \exp_not:N \l_@@_current_tl }
     \prop_put:NVx \exp_not:c { l_@@_named_ . _prop }
@@ -3048,6 +3044,12 @@
     \\ \\
     key~was~given~with~the~correct~information.
   }
+\msg_new:nnn { color } { unhandled-model }
+  {
+    Unhandled~color~model~in~LaTeX2e~value~"#1":
+    \\ \\
+    falling~back~on~grayscale.
+  }
 \msg_new:nnnn { color } { unknown-color }
   { Unknown~color~'#1'. }
   {
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index b3418503f..36db396ad 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -29,6 +29,7 @@ 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 \__color_backend_pickup:w on line ...
 Defining \l__color_backend_stack_int on line ...
 \l__color_backend_stack_int=\count...
 Defining \__kernel_color_backend_stack_init:Nnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 090808e0a..8785b8fe3 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -30,6 +30,7 @@ Defining \__kernel_backend_align_end: on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_named:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index ba24196eb..ba3648e6b 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -29,6 +29,7 @@ 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 \__color_backend_pickup:w on line ...
 Defining \l__color_backend_stack_int on line ...
 \l__color_backend_stack_int=\count...
 Defining \__kernel_color_backend_stack_init:Nnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 090808e0a..8785b8fe3 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -30,6 +30,7 @@ Defining \__kernel_backend_align_end: on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_named:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index ce9e001bc..563d67c95 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -27,6 +27,7 @@ Defining \__kernel_backend_literal_page:n on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index b3418503f..36db396ad 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -29,6 +29,7 @@ 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 \__color_backend_pickup:w on line ...
 Defining \l__color_backend_stack_int on line ...
 \l__color_backend_stack_int=\count...
 Defining \__kernel_color_backend_stack_init:Nnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 090808e0a..8785b8fe3 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -30,6 +30,7 @@ Defining \__kernel_backend_align_end: on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_named:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index ba24196eb..ba3648e6b 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -29,6 +29,7 @@ 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 \__color_backend_pickup:w on line ...
 Defining \l__color_backend_stack_int on line ...
 \l__color_backend_stack_int=\count...
 Defining \__kernel_color_backend_stack_init:Nnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 090808e0a..8785b8fe3 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -30,6 +30,7 @@ Defining \__kernel_backend_align_end: on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_named:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index ce9e001bc..563d67c95 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -27,6 +27,7 @@ Defining \__kernel_backend_literal_page:n on line ...
 Defining \__kernel_backend_scope_begin: on line ...
 Defining \__kernel_backend_scope_end: on line ...
 Defining \__color_backend_pickup:N on line ...
+Defining \__color_backend_pickup:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...





More information about the latex3-commits mailing list.