[latex3-commits] [git/LaTeX3-latex3-latex3] color-models: Require a PDF name for Separation color models (96f939129)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Jul 9 18:23:57 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : color-models
Link : https://github.com/latex3/latex3/commit/96f9391295b5df136c0d3f5f070f1c7ba62fa8bd
>---------------------------------------------------------------
commit 96f9391295b5df136c0d3f5f070f1c7ba62fa8bd
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Jul 9 17:23:57 2020 +0100
Require a PDF name for Separation color models
>---------------------------------------------------------------
96f9391295b5df136c0d3f5f070f1c7ba62fa8bd
l3experimental/l3color/l3color.dtx | 72 ++++++++++++++++++-------
l3experimental/l3color/testfiles/m3color003.lvt | 10 ++--
l3experimental/l3color/testfiles/m3color003.tlg | 7 +++
3 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 9627beeea..bec8b128c 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -312,7 +312,7 @@
%
% \begin{function}{\color_model_new:nnn}
% \begin{syntax}
-% \cs{color_model_new:nnn} \Arg{name} \Arg{family} \Arg{params}
+% \cs{color_model_new:nnn} \Arg{model} \Arg{family} \Arg{params}
% \end{syntax}
% Creates a new \meta{model} which is derived from the color model \meta{family}.
% The latter should be one of
@@ -325,12 +325,17 @@
% optional.
% \end{function}
%
-% For a \texttt{Separation} space, there is one \emph{compulsory} key, the
-% \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, and also creates a second model under the multiple
-% model approach described earlier.
+% For a \texttt{Separation} space, there are two \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, and also creates a second model under the multiple
+% model approach described earlier.
+% \end{itemize}
%
% \end{documentation}
%
@@ -1354,8 +1359,9 @@
%
% \begin{macro}{\color_model_new:nnn, \@@_model_new:nnn}
% \begin{macro}{\@@_model_separation:n}
+% \begin{macro}{\@@_model_separation:nn}
% \begin{macro}{\@@_model_separation:w}
-% \begin{macro}{\@@_model_separation:nnw}
+% \begin{macro}{\@@_model_separation:nnnw}
% \begin{macro}
% {
% \@@_model_separation_cmyk:nnnnn ,
@@ -1393,11 +1399,28 @@
}
}
% \end{macrocode}
+% Separations must have a \enquote{real} name, which is pretty easy to find.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_model_separation:n #1
+ {
+ \prop_get:NnNTF \l_@@_internal_prop { name }
+ \l_@@_internal_tl
+ {
+ \exp_args:NV \@@_model_separation:nn
+ \l_@@_internal_tl {#1}
+ }
+ {
+ \__kernel_msg_error:nnn { color }
+ { separation-requires-name } {#1}
+ }
+ }
+% \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.
+% 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.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_model_separation:n #1
+\cs_new_protected:Npx \@@_model_separation:nn #1#2
{
\prop_get:NnNTF \exp_not:N \l_@@_internal_prop { alternative-space }
\exp_not:N \l_@@_internal_tl
@@ -1405,18 +1428,18 @@
\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 {#1}
+ \exp_not:N \s_@@_stop {#2} {#1}
}
{
\__kernel_msg_error:nnn { color }
- { separation-requires-alternative } {#1}
+ { separation-requires-alternative } {#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
+ \exp_not:N \s_@@_stop ##4##5
}
{
\bool_lazy_or:nnTF
@@ -1426,7 +1449,7 @@
\__kernel_msg_error:nnn { color }
{ separation-requires-alternative } {#1}
}
- { \@@_model_separation:nnw {#4} {#1} #2 , 0 , 0 , 0 , 0 \s_@@_stop }
+ { \@@_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,
@@ -1437,10 +1460,10 @@
% data is set for that at all group levels, we need to work on a per-level
% basis.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_model_separation:nnw
- #1#2 #3 , #4 , #5 , #6 , #7 \s_@@_stop
+\cs_new_protected:Npn \@@_model_separation:nnnw
+ #1#2#3 #4 , #5 , #6 , #7 , #8 \s_@@_stop
{
- \cs_if_exist:cTF { @@_model_separation_ #2 :nnnnn }
+ \cs_if_exist:cTF { @@_model_separation_ #3 :nnnnn }
{
\tl_const:cn { c_@@_fallback_ #1 _tl } { 1 }
\cs_new_eq:cN { @@_parse_mix_ #1 :nw } \@@_parse_mix_gray:nw
@@ -1448,8 +1471,8 @@
{ {#1} { \@@_parse_number:n {##1} } }
\cs_new_protected:cpn { @@_backend_ #1 :n } ##1
{ \@@_backend_family_separation:nn {#1} {##1} }
- \use:c { @@_model_separation_ #2 :nnnnn }
- {#1} {#3} {#4} {#5} {#6}
+ \use:c { @@_model_separation_ #3 :nnnnn }
+ {#1} {#4} {#5} {#6} {#7}
\cs_new_protected:cpx { @@_model_ #1 _ white: }
{
\prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#1} { 0 }
@@ -1525,6 +1548,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Diagnostics}
%
@@ -1581,6 +1605,16 @@
\\ \\
key~was~given~with~the~correct~information.
}
+
+\__kernel_msg_new:nnnn { color } { separation-requires-name }
+ { Separation~color~space~'#1'~require~a~formal~name. }
+ {
+ LaTeX~has~been~asked~to~create~a~separation~color~space,~
+ but~no~\\ \\
+ \iow_indent:n { name = <formal~name> }
+ \\ \\
+ key~was~given~with~the~correct~information.
+ }
\__kernel_msg_new:nnnn { color } { unknown-color }
{ Unknown~color~'#1'. }
{
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index 36192ceb3..e38f15d42 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -149,7 +149,7 @@
\cs_set_protected:Npn \test:nn #1#2
{
\color_model_new:nnn { BarTone #1 } { Separation }
- { alternative-space = {#2} }
+ { name = BarTone~555~GN , alternative-space = {#2} }
\color_set:nnn { foo #1 } { BarTone #1 } { 0.5 }
\color_show:n { foo #1 }
}
@@ -165,8 +165,12 @@
\color_model_new:nnn { BarToneCMYK } { Separation } { }
\color_model_new:nnn { foo1 } { nope } { who-cares }
\color_model_new:nnn { foo2 } { separation } { }
- \color_model_new:nnn { foo3 } { separation } { alternative-space }
- \color_model_new:nnn { foo4 } { separation } { alternative-space = foo }
+ \color_model_new:nnn { foo2 } { separation }
+ { name = BarTone~555~GN }
+ \color_model_new:nnn { foo3 } { separation }
+ { name = BarTone~555~GN , alternative-space }
+ \color_model_new:nnn { foo4 } { separation }
+ { name = BarTone~555~GN , alternative-space = foo }
}
\TEST { Converting~new~models }
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index 6bfa00691..31b241718 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -245,6 +245,13 @@ For immediate help type H <return>.
l. ... }
LaTeX has been asked to use create a new color model of type 'nope', but this
type of model is not set up.
+! LaTeX3 Error: Separation color space 'foo2' require a formal name.
+For immediate help type H <return>.
+ ...
+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.
For immediate help type H <return>.
...
More information about the latex3-commits
mailing list.