[latex3-commits] [git/LaTeX3-latex3-pdfresources] main: add replacement for color.sty to test l3color integration (48deae9)
Ulrike Fischer
fischer at troubleshooting-tex.de
Tue Feb 23 17:43:46 CET 2021
Repository : https://github.com/latex3/pdfresources
On branch : main
Link : https://github.com/latex3/pdfresources/commit/48deae9b64657f84e9464be327978785a510ef05
>---------------------------------------------------------------
commit 48deae9b64657f84e9464be327978785a510ef05
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Tue Feb 23 17:43:46 2021 +0100
add replacement for color.sty to test l3color integration
>---------------------------------------------------------------
48deae9b64657f84e9464be327978785a510ef05
build.lua | 2 +
firstaid/color-ltx.sty | 221 +++++++++++++++++++++++++++++++++++++++++
hyperref-generic.dtx | 8 +-
pdfmanagement-firstaid.dtx | 27 ++++-
testfiles-dvips/colorpatch.lvt | 43 ++++++++
testfiles-dvips/colorpatch.tlg | 49 +++++++++
testfiles/colorpatch.lvt | 43 ++++++++
testfiles/colorpatch.tlg | 49 +++++++++
8 files changed, 438 insertions(+), 4 deletions(-)
diff --git a/build.lua b/build.lua
index 3f2db9e..16992de 100644
--- a/build.lua
+++ b/build.lua
@@ -16,6 +16,7 @@ if options["target"] == "ctan" then
"firstaid/hyperxmp-patches-tmp-ltx.sty",
"firstaid/pdflscape-ltx.sty",
"firstaid/xcolor-patches-tmp-ltx.sty",
+ "firstaid/color-ltx.sty",
}
else
sourcefiles = {"*.dtx","*.ins",
@@ -24,6 +25,7 @@ else
"firstaid/hyperxmp-patches-tmp-ltx.sty",
"firstaid/pdflscape-ltx.sty",
"firstaid/xcolor-patches-tmp-ltx.sty",
+ "firstaid/color-ltx.sty",
"support/pdfmanagement-regressiontest.sty",
"newpackages/new-bookmark.sty",
"newpackages/bkm-generic.def",
diff --git a/firstaid/color-ltx.sty b/firstaid/color-ltx.sty
new file mode 100644
index 0000000..60a55ad
--- /dev/null
+++ b/firstaid/color-ltx.sty
@@ -0,0 +1,221 @@
+%%
+%% This is file `color.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% color.dtx (with options: `package')
+%%
+%% The source is maintained by the LaTeX Project team and bug
+%% reports for it can be opened at https://latex-project.org/bugs/
+%% (but please observe conditions on bug reports sent to that address!)
+%%
+%%
+%% color.dtx Copyright (C) 1994--1999 David Carlisle
+%% Copyright (C) 2005-2020 David Carlisle, LaTeX3 Project
+%%
+%% This file is part of the Standard LaTeX `Graphics Bundle'.
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.3c or, at your option, any later version.
+%%
+%% This file has the LPPL maintenance status "maintained".
+%%
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{color-ltx}
+ [2021/02/22 v1.2d Standard LaTeX Color (patched for l3color) (DPC)]
+\edef\Gin at codes{%
+ \catcode`\noexpand\^^A\the\catcode`\^^A\relax
+ \catcode`\noexpand\"\the\catcode`\"\relax
+ \catcode`\noexpand\*\the\catcode`\*\relax
+ \catcode`\noexpand\!\the\catcode`\!\relax
+ \catcode`\noexpand\:\the\catcode`\:\relax}
+\catcode`\^^A=\catcode`\%
+\catcode`\"=12
+\catcode`\*=11
+\catcode`\!=12
+\catcode`\:=12
+\providecommand\Gin at driver{}
+\def\c at lor@error#1{%
+ \@latex at error{Undefined color #1}\@ehd}
+\DeclareOption{monochrome}{%
+ \def\c at lor@error#1{\PackageInfo{color}{Undefined color #1}}%
+ \AtEndOfPackage{%
+ \colors at false
+ \def\set at color{%
+ \c at lor@special\m at ne
+ {color push \current at color}\aftergroup\reset at color}%
+ \def\reset at color{\c at lor@special\m at ne{color pop}}%
+ \def\set at page@color{%
+ \c at lor@special\m at ne{background \current at color}}%
+ \def\define at color#1#2{%
+ \c at lor@special\m at ne{define #1 #2}}}}
+\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
+\newif\ifGin at setpagesize\Gin at setpagesizetrue
+\DeclareOption{setpagesize}{\Gin at setpagesizetrue}
+\DeclareOption{nosetpagesize}{\Gin at setpagesizefalse}
+\DeclareOption{dvips}{\def\Gin at driver{dvips.def}%
+ \def\c at lor@namefile{dvipsnam.def}}
+\DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
+\DeclareOption{dvipdf}{\def\Gin at driver{dvipdf.def}}
+\DeclareOption{dvipdfm}{\def\Gin at driver{dvipdfm.def}}
+\DeclareOption{dvipdfmx}{\def\Gin at driver{dvipdfmx.def}}
+\DeclareOption{pdftex}{\def\Gin at driver{pdftex.def}}
+\DeclareOption{luatex}{\def\Gin at driver{luatex.def}}
+\DeclareOption{dvisvgm}{\def\Gin at driver{dvisvgm.def}}
+\DeclareOption{xetex}{\def\Gin at driver{xetex.def}}
+\DeclareOption{dvipsone}{\def\Gin at driver{dvipsone.def}}
+\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
+\DeclareOption{emtex}{\def\Gin at driver{emtex.def}}
+\DeclareOption{dviwin}{\def\Gin at driver{dviwin.def}}
+\DeclareOption{oztex}{\ExecuteOptions{dvips}}
+\DeclareOption{textures}{\def\Gin at driver{textures.def}}
+\DeclareOption{pctexps}{\def\Gin at driver{pctexps.def}}
+\DeclareOption{pctexwin}{\def\Gin at driver{pctexwin.def}}
+\DeclareOption{pctexhp}{\def\Gin at driver{pctexhp.def}}
+\DeclareOption{pctex32}{\def\Gin at driver{pctex32.def}}
+\DeclareOption{truetex}{\def\Gin at driver{truetex.def}}
+\DeclareOption{tcidvi}{\def\Gin at driver{tcidvi.def}}
+\DeclareOption{vtex}{\def\Gin at driver{vtex.def}}
+\DeclareOption{dvipsnames}{\def\c at lor@namefile{dvipsnam.def}}
+\DeclareOption{nodvipsnames}{\let\c at lor@namefile\relax}
+\let\c at lor@usename\@gobble
+\DeclareOption{usenames}{%
+ \def\c at lor@usename#1{%
+ \expandafter\color at named\csname\string\color @#1\endcsname{#1}}}
+\DeclareRobustCommand\color{%
+ \@ifnextchar[\@undeclaredcolor\@declaredcolor}
+\def\@undeclaredcolor[#1]#2{%
+ \@ifundefined{color@#1}%
+ {\c at lor@error{model `#1'}}%
+ {\csname color@#1\endcsname\current at color{#2}%
+ \set at color}%
+ \ignorespaces}
+\def\@declaredcolor#1{%
+ \@ifundefined{\string\color @#1}%
+ {\c at lor@error{`#1'}}%
+ {\expandafter\let\expandafter\current at color
+ \csname\string\color @#1\endcsname
+ \set at color}%
+ \ignorespaces}
+\protected\def\textcolor#1#{\@textcolor{#1}}
+\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
+\protected\def\pagecolor{%
+ \begingroup
+ \let\ignorespaces\endgroup
+ \let\set at color\set at page@color
+ \color}
+\protected\def\nopagecolor{%
+ \@ifundefined{no at page@color}{%
+ \PackageInfo{color}{\string\nopagecolor\space is not supported}%
+ }{%
+ \no at page@color
+ }%
+}
+\protected\def\definecolor#1#2#3{%
+ \@ifundefined{color@#2}%
+ {\c at lor@error{model `#2'}}%
+ {\@ifundefined{\string\color @#1}{}%
+ {\PackageInfo{color}{Redefining color #1}}%
+ \csname color@#2\expandafter\endcsname
+ \csname\string\color @#1\endcsname{#3}}%
+ \@expl at color@set@@nnn{#1}{#2}{#3}%
+ }
+\protected\def\DefineNamedColor#1#2#3#4{%
+ \@ifundefined{define at color@#1}%
+ {\c at lor@error{model `#1'}}%
+ {\@ifundefined{color@#3}%
+ {\c at lor@error{model `#3'}}%
+ {\@ifundefined{col@#2}{}%
+ {\PackageInfo{color}{Redefining color #2 in named color model}}%
+ \csname color@#3\endcsname\@tempa{#4}%
+ \@expl at color@set@@nnn{#2}{#3}{#4}%
+ \csname define at color@#1\endcsname{#2}\@tempa
+ \c at lor@usename{#2}}}}
+\@onlypreamble\DefineNamedColor
+\protected\def\@expl at color@set@@nnn#1#2#3{}
+\ifdefined\ExplSyntaxOn
+ \ExplSyntaxOn
+ \cs_gset_protected:Npn \@expl at color@set@@nnn #1 #2 #3
+ {
+ \cs_if_exist:NT \color_set:nnn
+ { \cs_if_exist:cTF { __color_parse_model_ #2 :w }
+ {
+ \color_set:nnn {#1}{#2}{#3}
+ }
+ { %for dvi mode
+ \tl_if_eq:nnT{#2}{named}
+ {
+ \color_set:nn{#1}{#3}
+ }
+ }
+ }
+ }
+ \ExplSyntaxOff
+\fi
+\newif\ifcolors@
+\colors at true
+\def\c at lor@special#1#2{%
+ \edef\@tempa{\write#1{#2}}\@tempa}
+\InputIfFileExists{color.cfg}{}{}
+\ProcessOptions
+\if!\Gin at driver!
+ \PackageError{color}
+ {No driver specified}
+ {You should make a default driver option in a file \MessageBreak
+ color.cfg\MessageBreak
+ eg: \protect\ExecuteOptions{dvips}%
+ }
+\else
+ \PackageInfo{color}{Driver file: \Gin at driver}
+ \@ifundefined{ver@\Gin at driver}{\input{\Gin at driver}}{}
+\fi
+\@ifundefined{c at lor@namefile}{}{\input{\c at lor@namefile}}
+\protected\def\normalcolor{\let\current at color\default at color\set at color}
+\AtBeginDocument{\let\default at color\current at color}
+\def\color at block#1#2#3{%
+ {\set at color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
+\protected\def\colorbox#1#{\color at box{#1}}
+\def\color at box#1#2{\color at b@x\relax{\color#1{#2}}}
+\protected\def\fcolorbox#1#{\color at fbox{#1}}
+\def\color at fbox#1#2#3{%
+ \color at b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
+
+\long\def\color at b@x#1#2#3{%
+ \leavevmode
+ \setbox\z@\hbox{\kern\fboxsep{\set at color#3}\kern\fboxsep}%
+ \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
+ \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
+ {#1{#2\color at block{\wd\z@}{\ht\z@}{\dp\z@}%
+ \box\z@}}}
+\def\color at setgroup{\begingroup\set at color}
+\let\color at begingroup\begingroup
+\def\color at endgroup{\endgraf\endgroup}
+\def\color at hbox{\hbox\bgroup\color at begingroup}
+\def\color at vbox{\vbox\bgroup\color at begingroup}
+\def\color at endbox{\color at endgroup\egroup}
+\ifx\color at gray\@undefined
+ \ifx\color at rgb\@undefined
+ \else
+ \definecolor{black}{rgb}{0,0,0}
+ \definecolor{white}{rgb}{1,1,1}
+ \fi
+\else
+ \definecolor{black}{gray}{0}
+ \definecolor{white}{gray}{1}
+\fi
+\ifx\color at rgb\@undefined\else
+ \definecolor{red}{rgb}{1,0,0}
+ \definecolor{green}{rgb}{0,1,0}
+ \definecolor{blue}{rgb}{0,0,1}
+\fi
+\ifx\color at cmyk\@undefined\else
+ \definecolor{cyan}{cmyk}{1,0,0,0}
+ \definecolor{magenta}{cmyk}{0,1,0,0}
+ \definecolor{yellow}{cmyk}{0,0,1,0}
+\fi
+\Gin at codes
+\let\Gin at codes\relax
+\endinput
+%%
+%% End of file `color.sty'.
diff --git a/hyperref-generic.dtx b/hyperref-generic.dtx
index 972d306..c279519 100644
--- a/hyperref-generic.dtx
+++ b/hyperref-generic.dtx
@@ -133,7 +133,12 @@
% it is recommended for most options ---with the exception of a few mentioned below in
% section~\ref{sec:pkg-options}---to set them in \cs{hypersetup},
% not as package option.
-% \item If the package \pkg{color} is used it is currently recommended to define
+% \item This driver uses \pkg{l3color} for the colors. All colors
+% defined with \cs{color_set:nn} or \cs{color_set:nnn} will work.
+% Colors defined with \pkg{xcolor} will work if they don't use one of
+% the special color models not supported by \pkg{l3color} as
+% \pkg{pdfmanagement-firstaid} contains a patch for xcolor.
+% If the package \pkg{color} is used it is currently recommended to define
% colors after \pkg{hyperref}. This driver uses \pkg{l3color} for the colors,
% some special color models of \pkg{xcolor} won't work.
% \item Load a color package or graphicx to get the right page sizes.
@@ -815,7 +820,6 @@
% \end{macrocode}
% \begin{macrocode}
\ExplSyntaxOn
-\cs_gset_eq:NN \@expl at color@set@@@@nnn \color_set:nnn
\file_input:n {hyperref-colorschemes.def}
\ExplSyntaxOff
% \end{macrocode}
diff --git a/pdfmanagement-firstaid.dtx b/pdfmanagement-firstaid.dtx
index 047608b..08fbf85 100644
--- a/pdfmanagement-firstaid.dtx
+++ b/pdfmanagement-firstaid.dtx
@@ -71,7 +71,7 @@
{LaTeX PDF management testphase bundle / firstaid-patches}
%<@@=pdfmanagement>
-\clist_map_inline:nn {pgf,transparent,hyperxmp,pdflscape,xcolor}
+\clist_map_inline:nn {pgf,transparent,hyperxmp,pdflscape,xcolor,color}
{
\bool_new:c { g_@@_firstaid_#1_bool }
\bool_gset_true:c { g_@@_firstaid_#1_bool }
@@ -86,13 +86,36 @@
\msg_new:nnn { pdfmanagement } { firstaid }
{ loading~pdfmanagement~firstaid~code~for~#1 }
% \end{macrocode}
+% \subsection{\pkg{color}}
+%
+% \pkg{color} is not incompatible, but the new \pkg{hyperref} driver makes use of
+% \pkg{l3color} to set the colors. It is therefore necessary to patch some
+% internal \pkg{color} commands, so
+% that colors defined with its \cs{definecolor} command are known to \pkg{l3color} and
+% so \pkg{hyperref}. This only supports the color models from l3color (which covers
+% all standard model of the \pkg{color} package). The |named| model is mapped to
+% \cs{color_set:nn}.
+%
+% This patch serves also as test to check if this change can be safely
+% added to \pkg{color} later.
+% \begin{macrocode}
+\@ifundefined{color_set:nn}{
+\RequirePackage{l3color}}{}
+\bool_if:NT \g_@@_firstaid_color_bool
+ {
+ \declare at file@substitution{color.sty}{color-ltx.sty}
+ }
+% \end{macrocode}
+%
% \subsection{\pkg{xcolor}}
%
% \pkg{xcolor} is not incompatible, but the new \pkg{hyperref} driver makes use of
% \pkg{l3color} to set the colors. It is therefore necessary to patch \pkg{xcolor}, so
% that colors defined with its \cs{definecolor} command are known to \pkg{l3color} and
% so \pkg{hyperref}. This only supports the color model from l3color. Colors defined
-% with the models |cmy|, |tHsb| and |named| are silently ignored.
+% with the models |cmy| and |tHsb| are silently ignored.
+%
+% The |named| model is mapped to \cs{color_set:nn}.
%
% \begin{macrocode}
\@ifundefined{color_set:nn}{
diff --git a/testfiles-dvips/colorpatch.lvt b/testfiles-dvips/colorpatch.lvt
new file mode 100644
index 0000000..8a04f8b
--- /dev/null
+++ b/testfiles-dvips/colorpatch.lvt
@@ -0,0 +1,43 @@
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{}
+\RequirePackage{pdfmanagement-regressiontest}
+\documentclass{article}
+
+\usepackage{color}
+\input{dvipsnam.def}
+
+\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}
+\begin{document}
+abc
+\START
+\ExplSyntaxOn
+\TEST{show~rgb}
+ {
+ \color_show:n{testrgb}
+ }
+\TEST{show~RGB}
+ {
+ \color_show:n{testRGB}
+ }
+
+\TEST{show~cmyk}
+ {
+ \color_show:n{testcmyk}
+ }
+
+\TEST{show~named~copy~cmyk}
+ {
+ \color_show:n{anteater}
+ }
+
+\TEST{show~named~dvipsnam.def}
+ {
+ \color_show:n{duck}
+ }
+\ExplSyntaxOff
+
+\end{document}
\ No newline at end of file
diff --git a/testfiles-dvips/colorpatch.tlg b/testfiles-dvips/colorpatch.tlg
new file mode 100644
index 0000000..0034c1f
--- /dev/null
+++ b/testfiles-dvips/colorpatch.tlg
@@ -0,0 +1,49 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+============================================================
+TEST 1: show rgb
+============================================================
+The color testrgb has the properties:
+> model => rgb
+> rgb => 0.5 0.5 0.6.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 2: show RGB
+============================================================
+The color testRGB has the properties:
+> model => rgb
+> rgb => 0.39216 0.39216 0.39216.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 3: show cmyk
+============================================================
+The color testcmyk has the properties:
+> model => cmyk
+> cmyk => 0.5 0.5 0.6 0.4.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: show named copy cmyk
+============================================================
+The color anteater has the properties:
+> model => cmyk
+> cmyk => 0.5 0.5 0.6 0.4.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 5: show named dvipsnam.def
+============================================================
+The color duck has the properties:
+> model => cmyk
+> cmyk => 0.15 0.0 0.69 0.0.
+<recently read> }
+l. ... }
+============================================================
+[1
+] (colorpatch.aux)
diff --git a/testfiles/colorpatch.lvt b/testfiles/colorpatch.lvt
new file mode 100644
index 0000000..8a04f8b
--- /dev/null
+++ b/testfiles/colorpatch.lvt
@@ -0,0 +1,43 @@
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{}
+\RequirePackage{pdfmanagement-regressiontest}
+\documentclass{article}
+
+\usepackage{color}
+\input{dvipsnam.def}
+
+\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}
+\begin{document}
+abc
+\START
+\ExplSyntaxOn
+\TEST{show~rgb}
+ {
+ \color_show:n{testrgb}
+ }
+\TEST{show~RGB}
+ {
+ \color_show:n{testRGB}
+ }
+
+\TEST{show~cmyk}
+ {
+ \color_show:n{testcmyk}
+ }
+
+\TEST{show~named~copy~cmyk}
+ {
+ \color_show:n{anteater}
+ }
+
+\TEST{show~named~dvipsnam.def}
+ {
+ \color_show:n{duck}
+ }
+\ExplSyntaxOff
+
+\end{document}
\ No newline at end of file
diff --git a/testfiles/colorpatch.tlg b/testfiles/colorpatch.tlg
new file mode 100644
index 0000000..0034c1f
--- /dev/null
+++ b/testfiles/colorpatch.tlg
@@ -0,0 +1,49 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+============================================================
+TEST 1: show rgb
+============================================================
+The color testrgb has the properties:
+> model => rgb
+> rgb => 0.5 0.5 0.6.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 2: show RGB
+============================================================
+The color testRGB has the properties:
+> model => rgb
+> rgb => 0.39216 0.39216 0.39216.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 3: show cmyk
+============================================================
+The color testcmyk has the properties:
+> model => cmyk
+> cmyk => 0.5 0.5 0.6 0.4.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: show named copy cmyk
+============================================================
+The color anteater has the properties:
+> model => cmyk
+> cmyk => 0.5 0.5 0.6 0.4.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 5: show named dvipsnam.def
+============================================================
+The color duck has the properties:
+> model => cmyk
+> cmyk => 0.15 0.0 0.69 0.0.
+<recently read> }
+l. ... }
+============================================================
+[1
+] (colorpatch.aux)
More information about the latex3-commits
mailing list.