[latex3-commits] [git/LaTeX3-latex3-pdfresources] develop: improve xcolor patch to allow pstricks ps-type color definitions (bd82073)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun Mar 21 16:22:27 CET 2021


Repository : https://github.com/latex3/pdfresources
On branch  : develop
Link       : https://github.com/latex3/pdfresources/commit/bd82073cd7216552eb4f1bf90d164e35d6a81fef

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

commit bd82073cd7216552eb4f1bf90d164e35d6a81fef
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun Mar 21 16:22:27 2021 +0100

    improve xcolor patch to allow pstricks ps-type color definitions


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

bd82073cd7216552eb4f1bf90d164e35d6a81fef
 firstaid/xcolor-patches-tmp-ltx.sty                | 52 +++++++++++++++-------
 .../colorpatch.lvt => testfiles/xcolorpatch.lvt    | 10 ++++-
 testfiles/{colorpatch.tlg => xcolorpatch.tlg}      | 10 ++++-
 3 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/firstaid/xcolor-patches-tmp-ltx.sty b/firstaid/xcolor-patches-tmp-ltx.sty
index aec0fbb..eb08d80 100644
--- a/firstaid/xcolor-patches-tmp-ltx.sty
+++ b/firstaid/xcolor-patches-tmp-ltx.sty
@@ -4,23 +4,41 @@
 \@ifundefined{color_set:nn}{\RequirePackage{l3color}}{}
 
 \ExplSyntaxOn
-\cs_gset_protected:Npn \@expl at xcolor@set@@nnn #1 #2 #3
+% #1 is the color name
+% #2:  model or models
+% #3: value: either numbers or a color name
+% #4 is the type: named or ps
+\cs_gset_protected:Npn \@expl at xcolor@set@@nnnn #1 #2 #3 #4
     {
-      \cs_if_exist:cTF { __color_parse_model_ #2 :w }
-       {
-         \color_set:nnn {#1}{#2}{#3}
-       }
-       {
-         \tl_if_eq:nnTF{#2}{named}
-          {
-            \color_set:nn{#1}{#3}
-          }
-          {
-            %this is for multi models, it will break if there is model
-            %l3 doesn't know, but the case is rare, so accept it for now.
-            \color_set:nnn{#1}{#2}{#3}
-          }
-       }
+      \str_case:nnF {#4}
+        {
+          % we ignore the ps  type for now.
+          {ps}{}
+          {named}
+            {
+               \cs_if_exist:cT { __color_parse_model_ #2 :w }
+                 {
+                    \color_set:nnn {#1}{#2}{#3}
+                 }
+            }
+        }
+        {
+          \cs_if_exist:cTF { __color_parse_model_ #2 :w }
+           {
+             \color_set:nnn {#1}{#2}{#3}
+           }
+           {
+             \tl_if_eq:nnTF{#2}{named}%this the model not the type!
+               {
+                 \color_set:nn{#1}{#3}
+               }
+               {
+                 %this is for multi models, it will break if there is model
+                 %l3 doesn't know, but the case is rare, so accept it for now.
+                 \color_set:nnn{#1}{#2}{#3}
+               }
+           }
+        }
     }
  \cs_generate_variant:Nn \color_set:nn {ne}
  \cs_new_protected:Npn \@expl at xcolor@set@@ne #1 #2
@@ -58,7 +76,7 @@
 
 %\pretocmd{\XC at definec@lor}{\@expl at color@set@@nnn{#2}{#4}{#5}}{}{\fail}
 \def\XC at definec@lor[#1]#2[#3]#4#5%
- {\@expl at xcolor@set@@nnn{#2}{#4}{#5}%
+ {\@expl at xcolor@set@@nnnn{#2}{#4}{#5}{#1}%
   \begingroup
   \XC at sdef\@@cls{#1}\XC at edef\@@nam{#2}\edef\colornameprefix{#3}%
   \XC at logdef\@@nam
diff --git a/testfiles-dvips/colorpatch.lvt b/testfiles/xcolorpatch.lvt
similarity index 82%
copy from testfiles-dvips/colorpatch.lvt
copy to testfiles/xcolorpatch.lvt
index 8a04f8b..998daa5 100644
--- a/testfiles-dvips/colorpatch.lvt
+++ b/testfiles/xcolorpatch.lvt
@@ -3,14 +3,15 @@
 \RequirePackage{pdfmanagement-regressiontest}
 \documentclass{article}
 
-\usepackage{color}
-\input{dvipsnam.def}
+\usepackage[dvipsnames]{xcolor}
 
 \definecolor{testrgb}{rgb}{0.5,0.5,0.6}
 \definecolor{testRGB}{RGB}{100,100,100}
 \definecolor{testcmyk}{cmyk}{0.5,0.5,0.6,0.4}
 \definecolor{anteater}{named}{testcmyk}
 \definecolor{duck}{named}{GreenYellow}
+
+\definecolor[ps]{PS}{gray}{tx at Dict begin Rand end}
 \begin{document}
 abc
 \START
@@ -38,6 +39,11 @@ abc
  {
    \color_show:n{duck}
  }
+ 
+\TEST{show~ps}
+ {
+   \color_show:n{PS}
+ } 
 \ExplSyntaxOff
 
 \end{document} 
\ No newline at end of file
diff --git a/testfiles/colorpatch.tlg b/testfiles/xcolorpatch.tlg
similarity index 85%
copy from testfiles/colorpatch.tlg
copy to testfiles/xcolorpatch.tlg
index 0034c1f..69945f1 100644
--- a/testfiles/colorpatch.tlg
+++ b/testfiles/xcolorpatch.tlg
@@ -45,5 +45,13 @@ The color duck has the properties:
 <recently read> }
 l. ... }
 ============================================================
+============================================================
+TEST 6: show ps
+============================================================
+The color PS is undefined.
+> .
+<recently read> }
+l. ... }
+============================================================
 [1
-] (colorpatch.aux)
+] (xcolorpatch.aux)





More information about the latex3-commits mailing list.