[latex3-commits] [git/LaTeX3-latex3-latex3] color-models: Split alternative-space color set up (64427891e)
Joseph Wright
joseph.wright at morningstar2.co.uk
Wed Jul 15 12:12:58 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : color-models
Link : https://github.com/latex3/latex3/commit/64427891ed8d59126c60d28893443962efd4f846
>---------------------------------------------------------------
commit 64427891ed8d59126c60d28893443962efd4f846
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Jul 15 11:12:46 2020 +0100
Split alternative-space color set up
This will be vital to cover CIE-Lab.
>---------------------------------------------------------------
64427891ed8d59126c60d28893443962efd4f846
l3experimental/l3color/l3color.dtx | 127 +++++++++++----------
l3experimental/l3color/testfiles/m3color003.lvt | 19 +--
.../l3color/testfiles/m3color003.ptex.tlg | 20 ++--
l3experimental/l3color/testfiles/m3color003.tlg | 20 ++--
.../l3color/testfiles/m3color003.uptex.tlg | 20 ++--
.../l3color/testfiles/m3color003.xetex.tlg | 20 ++--
6 files changed, 124 insertions(+), 102 deletions(-)
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index ce3484bd2..4fbde6cf4 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -325,15 +325,16 @@
% optional.
% \end{function}
%
-% For a \texttt{Separation} space, there are two \emph{compulsory} keys.
+% For a \texttt{Separation} space, there are three \emph{compulsory} keys.
% \begin{itemize}
% \item \texttt{name} The name of the Separation, for example the formal
% name of a spot color ink. Such a \meta{name} may contain spaces, etc.,
% which are not permitted in the \meta{model}.
-% \item \texttt{alternative-space} This should the form
-% \meta{model}\texttt{:}\meta{values}, for example \texttt{rgb:0.1,0.2,0.3}.
-% This information is used by the PDF application if the \texttt{Separation}
-% is not available.
+% \item \texttt{alternative-model} An alternative device colorspace, one of
+% \texttt{cmyk}, \texttt{rgb} or \texttt{gray}
+% \item \texttt{alternative-values} A comma-separated list of values
+% appropriate to the \texttt{alternative-model}. This information is used by
+% the PDF application if the \texttt{Separation} is not available.
% \end{itemize}
%
% \end{documentation}
@@ -1366,8 +1367,8 @@
% \begin{macro}{\color_model_new:nnn, \@@_model_new:nnn}
% \begin{macro}{\@@_model_separation:n}
% \begin{macro}{\@@_model_separation:nn}
+% \begin{macro}{\@@_model_separation:nnn}
% \begin{macro}{\@@_model_separation:w}
-% \begin{macro}{\@@_model_separation:nnnw}
% \begin{macro}
% {
% \@@_model_separation_cmyk:nnnnnn ,
@@ -1422,41 +1423,41 @@
}
}
% \end{macrocode}
-% For separations, we know that there must be an alternative color space,
-% and it has to be one of |cmyk|,|gray| or |rgb|. The format
-% is slightly tricky, so we use |x|-type expansion to sort it. We also shuffle
-% the two names here: \TeX{} one first makes most sense further on.
+% We have two keys to find at this stage: the alternative space model
+% and linked values.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_model_separation:nn #1#2
+\cs_new_protected:Npn \@@_model_separation:nn #1#2
{
- \prop_get:NnNTF \exp_not:N \l_@@_internal_prop { alternative-space }
- \exp_not:N \l_@@_internal_tl
+ \prop_get:NnNTF \l_@@_internal_prop { alternative-model }
+ \l_@@_internal_tl
{
- \exp_not:N \exp_after:wN \exp_not:N \@@_model_separation:w
- \exp_not:N \l_@@_internal_tl
- \token_to_str:N : \token_to_str:N :
- \exp_not:N \s_@@_stop {#2} {#1}
+ \exp_args:NV \@@_model_separation:nnn
+ \l_@@_internal_tl {#2} {#1}
}
{
\__kernel_msg_error:nnn { color }
- { separation-requires-alternative } {#2}
+ { separation-alternative-model } {#2}
}
}
-\use:x
- {
- \cs_new_protected:Npn \exp_not:N \@@_model_separation:w
- ##1 \token_to_str:N : ##2 \token_to_str:N : ##3
- \exp_not:N \s_@@_stop ##4##5
- }
+\cs_new_protected:Npn \@@_model_separation:nnn #1#2#3
{
- \bool_lazy_or:nnTF
- { \tl_if_blank_p:n {#1} }
- { \tl_if_blank_p:n {#2} }
+ \cs_if_exist:cTF { @@_model_separation_ #1 :nnnnnn }
+ {
+ \prop_get:NnNTF \l_@@_internal_prop { alternative-values }
+ \l_@@_internal_tl
+ {
+ \exp_after:wN \@@_model_separation:w \l_@@_internal_tl
+ , 0 , 0 , 0 , 0 \s_@@_stop {#2} {#3} {#1}
+ }
+ {
+ \__kernel_msg_error:nnn { color }
+ { separation-alternative-values } {#2}
+ }
+ }
{
\__kernel_msg_error:nnn { color }
- { separation-requires-alternative } {#1}
+ { unknown-alternative-model } {#1}
}
- { \@@_model_separation:nnnw {#4} {#5} {#1} #2 , 0 , 0 , 0 , 0 \s_@@_stop }
}
% \end{macrocode}
% As each alternative space leads to a different requirement for conversion,
@@ -1469,35 +1470,28 @@
% of the colorspace: we use a simple tracking number for general usage
% as this is a clear namespace without issues of escaping chars.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_model_separation:nnnw
- #1#2#3 #4 , #5 , #6 , #7 , #8 \s_@@_stop
- {
- \cs_if_exist:cTF { @@_model_separation_ #3 :nnnnnn }
+\cs_new_protected:Npn \@@_model_separation:w
+ #1 , #2 , #3 , #4 , #5 \s_@@_stop #6#7#8
+ {
+ \int_gincr:N \g_@@_separation_int
+ \tl_const:cn { c_@@_fallback_ #6 _tl } { 1 }
+ \cs_new_eq:cN { @@_parse_mix_ #6 :nw } \@@_parse_mix_gray:nw
+ \cs_new:cpn { @@_parse_model_ #6 :w } ##1 , ##2 \s_@@_stop
+ { {#6} { \@@_parse_number:n {##1} } }
+ \cs_new_protected:cpx { @@_backend_ #6 :n } ##1
{
- \int_gincr:N \g_@@_separation_int
- \tl_const:cn { c_@@_fallback_ #1 _tl } { 1 }
- \cs_new_eq:cN { @@_parse_mix_ #1 :nw } \@@_parse_mix_gray:nw
- \cs_new:cpn { @@_parse_model_ #1 :w } ##1 , ##2 \s_@@_stop
- { {#1} { \@@_parse_number:n {##1} } }
- \cs_new_protected:cpx { @@_backend_ #1 :n } ##1
- {
- \@@_backend_family_separation:nn
- { l3color \int_use:N \g_@@_separation_int } {##1}
- }
- \use:c { @@_model_separation_ #3 :nnnnnn }
- {#1} {#2} {#4} {#5} {#6} {#7}
- \cs_new_protected:cpx { @@_model_ #1 _ white: }
- {
- \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#1} { 0 }
- \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
- { \group_insert_after:N \exp_not:c { @@_model_ #1 _ white: } }
- }
- \use:c { @@_model_ #1 _ white: }
+ \@@_backend_family_separation:nn
+ { l3color \int_use:N \g_@@_separation_int } {##1}
}
+ \use:c { @@_model_separation_ #8 :nnnnnn }
+ {#6} {#7} {#1} {#2} {#3} {#4}
+ \cs_new_protected:cpx { @@_model_ #6 _white: }
{
- \__kernel_msg_error:nnn { color }
- { separation-requires-alternative } {#1}
+ \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#6} { 0 }
+ \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
+ { \group_insert_after:N \exp_not:c { @@_model_ #6 _ white: } }
}
+ \use:c { @@_model_ #6 _white: }
}
\cs_new_protected:Npn \@@_model_separation_cmyk:nnnnnn #1#2#3#4#5#6
{
@@ -1637,16 +1631,24 @@
LaTeX~was~asked~to~define~a~new~color~model~called~'#1',~but~
this~color~model~already~exists.
}
-\__kernel_msg_new:nnnn { color } { separation-requires-alternative }
- { Separation~color~space~'#1'~require~an~alternative~space. }
+\__kernel_msg_new:nnnn { color } { separation-alternative-model }
+ { Separation~color~space~'#1'~require~an~alternative~model. }
{
LaTeX~has~been~asked~to~create~a~separation~color~space,~
but~no~\\ \\
- \iow_indent:n { alternative-space = <model>:<value(s)> }
+ \iow_indent:n { alternative-model = <model> }
+ \\ \\
+ key~was~given~with~the~correct~information.
+ }
+\__kernel_msg_new:nnnn { color } { separation-alternative-values }
+ { Separation~color~space~'#1'~require~values~for~the~alternative~space. }
+ {
+ LaTeX~has~been~asked~to~create~a~separation~color~space,~
+ but~no~\\ \\
+ \iow_indent:n { alternative-values = <model> }
\\ \\
key~was~given~with~the~correct~information.
}
-
\__kernel_msg_new:nnnn { color } { separation-requires-name }
{ Separation~color~space~'#1'~require~a~formal~name. }
{
@@ -1662,6 +1664,15 @@
LaTeX~has~been~asked~to~use~a~color~named~'#1',~
but~this~has~never~been~defined.
}
+\__kernel_msg_new:nnnn { color } { unknown-alternative-model }
+ { Separation~color~space~'#1'~require~an~valid~alternative~space. }
+ {
+ LaTeX~has~been~asked~to~create~a~separation~color~space,~
+ but~the~model~given~as\\ \\
+ \iow_indent:n { alternative-model = <model> }
+ \\ \\
+ is~unknown.
+ }
\__kernel_msg_new:nnnn { color } { unknown-export-format }
{ Unknown~export~format~'#1'. }
{
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index e38f15d42..6977d9772 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -148,16 +148,19 @@
\OMIT
\cs_set_protected:Npn \test:nn #1#2
{
- \color_model_new:nnn { BarTone #1 } { Separation }
- { name = BarTone~555~GN , alternative-space = {#2} }
+ \exp_args:Nnnx \color_model_new:nnn { BarTone #1 } { Separation }
+ {
+ name = BarTone~555~GN ,
+ alternative-model = \str_foldcase:n {#1} ,
+ alternative-values = {#2}
+ }
\color_set:nnn { foo #1 } { BarTone #1 } { 0.5 }
\color_show:n { foo #1 }
}
- \cs_generate_variant:Nn \test:nn { nx }
\TIMO
- \test:nx { CMYK } { cmyk \token_to_str:N : 0.1 , 0.2 , 0.3 , 0.4 }
- \test:nx { RGB } { rgb \token_to_str:N : 0.1 , 0.2 , 0.3 }
- \test:nx { Gray } { gray \token_to_str:N : 0.1 }
+ \test:nn { CMYK } { 0.1 , 0.2 , 0.3 , 0.4 }
+ \test:nn { RGB } { 0.1 , 0.2 , 0.3 }
+ \test:nn { Gray } { 0.1 }
}
\TEST { Creating~new~models:~errors }
@@ -168,9 +171,9 @@
\color_model_new:nnn { foo2 } { separation }
{ name = BarTone~555~GN }
\color_model_new:nnn { foo3 } { separation }
- { name = BarTone~555~GN , alternative-space }
+ { name = BarTone~555~GN , alternative-model }
\color_model_new:nnn { foo4 } { separation }
- { name = BarTone~555~GN , alternative-space = foo }
+ { name = BarTone~555~GN , alternative-model = foo }
}
\TEST { Converting~new~models }
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index c9f229c84..b56b4f133 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -257,34 +257,36 @@ l. ... }
LaTeX has been asked to create a separation color space, but no
name=<formal name>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo2' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo2' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Missing/extra '=' in 'alternative-space' (in '..._keyval:Nn')
+! LaTeX3 Error: Missing/extra '=' in 'alternative-model' (in '..._keyval:Nn')
Type <return> to continue.
...
l. ... }
LaTeX does not know anything more about this error, sorry.
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
-! LaTeX3 Error: Separation color space 'foo3' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo3' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo' require an valid alternative
+(LaTeX3) space.
For immediate help type H <return>.
...
l. ... }
-LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
-key was given with the correct information.
+LaTeX has been asked to create a separation color space, but the model given
+as
+ alternative-model=<model>
+is unknown.
============================================================
============================================================
TEST 9: Converting new models
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index 31b241718..d4ee5e700 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -252,34 +252,36 @@ l. ... }
LaTeX has been asked to create a separation color space, but no
name=<formal name>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo2' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo2' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Missing/extra '=' in 'alternative-space' (in '..._keyval:Nn')
+! LaTeX3 Error: Missing/extra '=' in 'alternative-model' (in '..._keyval:Nn')
Type <return> to continue.
...
l. ... }
LaTeX does not know anything more about this error, sorry.
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
-! LaTeX3 Error: Separation color space 'foo3' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo3' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo' require an valid alternative
+(LaTeX3) space.
For immediate help type H <return>.
...
l. ... }
-LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
-key was given with the correct information.
+LaTeX has been asked to create a separation color space, but the model given
+as
+ alternative-model=<model>
+is unknown.
============================================================
============================================================
TEST 9: Converting new models
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index c9f229c84..b56b4f133 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -257,34 +257,36 @@ l. ... }
LaTeX has been asked to create a separation color space, but no
name=<formal name>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo2' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo2' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Missing/extra '=' in 'alternative-space' (in '..._keyval:Nn')
+! LaTeX3 Error: Missing/extra '=' in 'alternative-model' (in '..._keyval:Nn')
Type <return> to continue.
...
l. ... }
LaTeX does not know anything more about this error, sorry.
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
-! LaTeX3 Error: Separation color space 'foo3' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo3' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo' require an valid alternative
+(LaTeX3) space.
For immediate help type H <return>.
...
l. ... }
-LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
-key was given with the correct information.
+LaTeX has been asked to create a separation color space, but the model given
+as
+ alternative-model=<model>
+is unknown.
============================================================
============================================================
TEST 9: Converting new models
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index ad4f83587..b3b3145ac 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -252,34 +252,36 @@ l. ... }
LaTeX has been asked to create a separation color space, but no
name=<formal name>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo2' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo2' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Missing/extra '=' in 'alternative-space' (in '..._keyval:Nn')
+! LaTeX3 Error: Missing/extra '=' in 'alternative-model' (in '..._keyval:Nn')
Type <return> to continue.
...
l. ... }
LaTeX does not know anything more about this error, sorry.
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
-! LaTeX3 Error: Separation color space 'foo3' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo3' require an alternative model.
For immediate help type H <return>.
...
l. ... }
LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
+ alternative-model=<model>
key was given with the correct information.
-! LaTeX3 Error: Separation color space 'foo' require an alternative space.
+! LaTeX3 Error: Separation color space 'foo' require an valid alternative
+(LaTeX3) space.
For immediate help type H <return>.
...
l. ... }
-LaTeX has been asked to create a separation color space, but no
- alternative-space=<model>:<value(s)>
-key was given with the correct information.
+LaTeX has been asked to create a separation color space, but the model given
+as
+ alternative-model=<model>
+is unknown.
============================================================
============================================================
TEST 9: Converting new models
More information about the latex3-commits
mailing list.