[latex3-commits] [l3svn] 04/04: Pass color to driver code explicitly
noreply at latex-project.org
noreply at latex-project.org
Thu Oct 26 00:00:23 CEST 2017
This is an automated email from the git hooks/post-receive script.
joseph pushed a commit to branch master
in repository l3svn.
commit d9a489023411da16a885556a5b67370b2b03d1ab
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Oct 25 22:59:42 2017 +0100
Pass color to driver code explicitly
This is likely a better long-term plan: have interfaces even for modules
at the kernel level.
---
l3kernel/l3color.dtx | 5 +-
l3kernel/l3drivers.dtx | 106 ++++++++++++-----------------
l3kernel/testfiles/m3expl001.luatex.tlg | 6 +-
l3kernel/testfiles/m3expl001.ptex.tlg | 8 +--
l3kernel/testfiles/m3expl001.tlg | 6 +-
l3kernel/testfiles/m3expl001.uptex.tlg | 8 +--
l3kernel/testfiles/m3expl001.xetex.tlg | 8 +--
l3kernel/testfiles/m3expl003.luatex.tlg | 6 +-
l3kernel/testfiles/m3expl003.ptex.tlg | 8 +--
l3kernel/testfiles/m3expl003.tlg | 6 +-
l3kernel/testfiles/m3expl003.uptex.tlg | 8 +--
l3kernel/testfiles/m3expl003.xetex.tlg | 8 +--
l3trial/l3color-extras/l3color-extras.dtx | 2 +-
13 files changed, 86 insertions(+), 99 deletions(-)
diff --git a/l3kernel/l3color.dtx b/l3kernel/l3color.dtx
index 404df77..9e6641a 100644
--- a/l3kernel/l3color.dtx
+++ b/l3kernel/l3color.dtx
@@ -139,7 +139,10 @@
% \begin{macrocode}
\cs_new_protected:Npn \color_ensure_current:
{
- \__driver_color_ensure_current:
+%<*package>
+ \__driver_color_pickup:N \l__color_current_tl
+%</package>
+ \__driver_color_select:V \l__color_current_tl
\group_insert_after:N \__driver_color_reset:
}
% \end{macrocode}
diff --git a/l3kernel/l3drivers.dtx b/l3kernel/l3drivers.dtx
index 368ac2f..b75f9b2 100644
--- a/l3kernel/l3drivers.dtx
+++ b/l3kernel/l3drivers.dtx
@@ -123,16 +123,24 @@
%
% \section{Color support}
%
-% \begin{function}[added = 2011-09-03, updated = 2012-05-18]
-% {\__driver_color_ensure_current:}
+% \begin{function}[added = 2017-10-25]
+% {\__driver_color_select:n, \__driver_color_select:V}
% \begin{syntax}
-% \cs{__driver_color_ensure_current:}
+% \cs{__driver_color_select:n} \Arg{color}
% \end{syntax}
-% Ensures that the color used to typeset material is that which was
-% set when the material was placed in a box. This function is therefore
-% required inside any \enquote{color safe} box to ensure that the box may
-% be inserted in a location where the foreground color has been altered,
-% while preserving the color used in the box.
+% Selects the \meta{color} (which is given in low-level format: a
+% \meta{model} followed by a space and one or more space-separated
+% axes).
+% \end{function}
+%
+% \begin{function}[added = 2017-10-25]
+% {\__driver_color_pickup:N}
+% \begin{syntax}
+% \cs{__driver_color_pickup:N} \meta{tl}
+% \end{syntax}
+% In \LaTeXe{} package mode, collects data on the current color from
+% \tn{current at color} and stores it in the low-level format used by \pkg{expl3}
+% in the \meta{tl}.
% \end{function}
%
% \begin{function}[added = 2017-10-24]
@@ -519,31 +527,31 @@
%<*dvisvgm|dvipdfmx|dvips|xdvipdfmx>
% \end{macrocode}
%
-% \begin{macro}[aux]{\@@_color_pickup:}
+% \begin{macro}[int]{\@@_color_pickup:N}
% 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).
% \begin{macrocode}
%<*package>
-\cs_new_protected:Npn \@@_color_pickup: { }
+\cs_new_protected:Npn \@@_color_pickup:N #1 { }
\AtBeginDocument
{
\@ifpackageloaded { color }
{
- \cs_set_protected:Npn \@@_color_pickup:
+ \cs_set_protected:Npn \@@_color_pickup:N #1
{
\exp_args:NV \tl_if_head_is_space:nTF \current at color
{
- \tl_set:Nx \l__color_current_tl
+ \tl_set:Nx #1
{
spot ~
\exp_args:wN \use:n \current at color \c_space_tl 1
}
}
- { \exp_args:wN \@@_color_pickup_aux:w \current at color \q_stop }
+ { \exp_args:wN \@@_color_pickup_aux:w \current at color \q_stop #1 }
}
- \cs_new_protected:Npn \@@_color_pickup_aux:w #1 ~ #2 \q_stop
- { \tl_set:Nn \l__color_current_tl { #1 ~ #2 } }
+ \cs_new_protected:Npn \@@_color_pickup_aux:w #1 ~ #2 \q_stop #3
+ { \tl_set:Nn #3 { #1 ~ #2 } }
}
{ }
}
@@ -551,8 +559,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[int]{\@@_color_ensure_current:}
-% \begin{macro}[int]{\@@_color_select:}
+% \begin{macro}[int]{\@@_color_select:n, \@@_color_select:V}
% \begin{macro}[aux, EXP]{\@@_convert_model:w}
% \begin{macro}[aux, EXP]{\@@_color_convert_spot:}
% \begin{macro}[aux, EXP]{\@@_color_convert_spot:w}
@@ -563,30 +570,21 @@
% created for mixing named colors. (They would not be supported at the moment,
% but still need to be handled.)
% \begin{macrocode}
-\cs_new_protected:Npn \@@_color_ensure_current:
- {
-%<*package>
- \@@_color_pickup:
-%</package>
- \@@_color_select:
- }
-\cs_new_protected:Npn \@@_color_select:
+\cs_new_protected:Npn \@@_color_select:n #1
{
\tex_special:D
{
color~push~
\cs_if_exist_use:cF
- {
- @@_color_convert_
- \exp_after:wN \@@_convert_model:w \l__color_current_tl \q_stop
- :
- }
- { \tl_use:N \l__color_current_tl }
+ { @@_color_convert_ \@@_convert_model:w #1 \q_stop :n }
+ { \use:n }
+ {#1}
}
}
+\cs_generate_variant:Nn \@@_color_select:n { V }
\cs_new:Npn \@@_convert_model:w #1 ~ #2 \q_stop {#1}
-\cs_new:Npn \@@_color_convert_spot:
- { \exp_after:wN \@@_color_convert_spot:w \l__color_current_tl \q_stop }
+\cs_new:Npn \@@_color_convert_spot:n #1
+ { \@@_color_convert_spot:w #1 \q_stop }
\cs_new:Npn \@@_color_convert_spot:w #1 ~ #2 ~ #3 \q_stop
{ \c_space_tl #2 }
\cs_new_protected:Npn \@@_color_reset:
@@ -597,7 +595,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\@@_color_page:}
% Simple application of color support at the driver level.
@@ -625,7 +622,7 @@
%<*pdfmode>
% \end{macrocode}
%
-% \begin{macro}[aux]{\@@_color_pickup:}
+% \begin{macro}[aux]{\@@_color_pickup:N}
% \begin{macro}[aux]{\@@_color_pickup_aux: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
@@ -635,38 +632,34 @@
% \pkg{xcolor} sets it to be instructions to generate a colour
% \begin{macrocode}
%<*package>
-\cs_new_protected:Npn \@@_color_pickup: { }
+\cs_new_protected:Npn \@@_color_pickup:N #1 { }
\AtBeginDocument
{
\@ifpackageloaded { color }
{
- \cs_set_protected:Npn \@@_color_pickup:
+ \cs_set_protected:Npn \@@_color_pickup:N #1
{
\exp_last_unbraced:Nx \@@_color_pickup_aux:w
- { \current at color } ~ 0 ~ 0 ~ 0 \q_stop
+ { \current at color } ~ 0 ~ 0 ~ 0 \q_stop #1
}
\cs_new_protected:Npn \@@_color_pickup_aux:w
- #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \q_stop
+ #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \q_stop #7
{
\str_if_eq:nnTF {#2} { g }
- { \tl_set:Nn \l__color_current_tl { gray ~ #1 } }
+ { \tl_set:Nn #7 { gray ~ #1 } }
{
\str_if_eq:nnTF {#4} { rg }
- { \tl_set:Nn \l__color_current_tl { rgb ~ #1 ~ #2 ~ #3 } }
+ { \tl_set:Nn #7 { rgb ~ #1 ~ #2 ~ #3 } }
{
\str_if_eq:nnTF {#5} { k }
- {
- \tl_set:Nn \l__color_current_tl
- { cmyk ~ #1 ~ #2 ~ #3 ~ #4 }
- }
+ { \tl_set:Nn #7 { cmyk ~ #1 ~ #2 ~ #3 ~ #4 } }
{
\str_if_eq:nnTF {#2} { cs }
{
- \tl_set:Nx \l__color_current_tl
- { spot ~ \use_none:n #1 ~ #5 }
+ \tl_set:Nx #7 { spot ~ \use_none:n #1 ~ #5 }
}
{
- \tl_set:Nn \l__color_current_tl { gray ~ 0 }
+ \tl_set:Nn #7 { gray ~ 0 }
}
}
}
@@ -688,8 +681,7 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}[int]{\@@_color_ensure_current:}
-% \begin{macro}[int]{\@@_color_select:}
+% \begin{macro}[int]{\@@_color_select:n, \@@_color_select:V}
% \begin{macro}[aux, EXP]{\@@_color_convert:w}
% \begin{macro}[aux, EXP]
% {
@@ -704,26 +696,19 @@
% Most of the conversions are trivial but the need to cover spot colors
% makes life slightly more interesting.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_color_ensure_current:
- {
-%<*package>
- \@@_color_pickup:
-%</package>
- \@@_color_select:
- }
-\cs_new_protected:Npx \@@_color_select:
+\cs_new_protected:Npx \@@_color_select:n #1
{
\cs_if_exist:NTF \luatex_pdfextension:D
{ \luatex_pdfextension:D colorstack }
{ \pdftex_pdfcolorstack:D }
\exp_not:N \l_@@_color_stack_int push
{
- \exp_not:N \exp_after:wN
\exp_not:N \@@_color_convert:w
- \exp_not:N \l__color_current_tl
+ #1
\exp_not:N \q_stop
}
}
+\cs_generate_variant:Nn \@@_color_select:n { V }
\cs_new:Npn \@@_color_convert:w #1 ~ #2 \q_stop
{ \use:c { @@_color_convert_ #1 :w } #2 \q_stop }
\cs_new:Npn \@@_color_convert_gray:w #1 \q_stop
@@ -748,7 +733,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\@@_page_color:}
% Direct PDF output doesn't natively support page color, requiring instead
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 80e26f6..4b32829 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5747,11 +5747,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3pdfmode.def
-Defining \__driver_color_pickup: on line ...
+Defining \__driver_color_pickup:N on line ...
Defining \l__driver_color_stack_int on line ...
\l__driver_color_stack_int=\count193
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_color_convert:w on line ...
Defining \__driver_color_convert_gray:w on line ...
Defining \__driver_color_convert_cmyk:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index bd77b31..f926a47 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5738,11 +5738,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3dvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 05e32ce..43185a9 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5939,11 +5939,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3pdfmode.def
-Defining \__driver_color_pickup: on line ...
+Defining \__driver_color_pickup:N on line ...
Defining \l__driver_color_stack_int on line ...
\l__driver_color_stack_int=\count195
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_color_convert:w on line ...
Defining \__driver_color_convert_gray:w on line ...
Defining \__driver_color_convert_cmyk:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 0e93f91..7a1159e 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5937,11 +5937,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3dvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index d4d2326..485ba96 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5721,11 +5721,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3xdvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 80e26f6..4b32829 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5747,11 +5747,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3pdfmode.def
-Defining \__driver_color_pickup: on line ...
+Defining \__driver_color_pickup:N on line ...
Defining \l__driver_color_stack_int on line ...
\l__driver_color_stack_int=\count193
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_color_convert:w on line ...
Defining \__driver_color_convert_gray:w on line ...
Defining \__driver_color_convert_cmyk:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index bd77b31..f926a47 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5738,11 +5738,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3dvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 05e32ce..43185a9 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5939,11 +5939,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3pdfmode.def
-Defining \__driver_color_pickup: on line ...
+Defining \__driver_color_pickup:N on line ...
Defining \l__driver_color_stack_int on line ...
\l__driver_color_stack_int=\count195
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_color_convert:w on line ...
Defining \__driver_color_convert_gray:w on line ...
Defining \__driver_color_convert_cmyk:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 0e93f91..7a1159e 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5937,11 +5937,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3dvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index d4d2326..485ba96 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5721,11 +5721,11 @@ Defining key expl/log-functions/true on line ...
Defining key expl/log-functions/false on line ...
Defining \c__expl_def_ext_tl on line ...
(l3xdvipdfmx.def
-Defining \__driver_color_pickup: on line ...
-Defining \__driver_color_ensure_current: on line ...
-Defining \__driver_color_select: on line ...
+Defining \__driver_color_pickup:N on line ...
+Defining \__driver_color_select:n on line ...
+Defining \__driver_color_select:V on line ...
Defining \__driver_convert_model:w on line ...
-Defining \__driver_color_convert_spot: on line ...
+Defining \__driver_color_convert_spot:n on line ...
Defining \__driver_color_convert_spot:w on line ...
Defining \__driver_color_reset: on line ...
Defining \__driver_color_page: on line ...
diff --git a/l3trial/l3color-extras/l3color-extras.dtx b/l3trial/l3color-extras/l3color-extras.dtx
index 3875ca9..b59ae3a 100644
--- a/l3trial/l3color-extras/l3color-extras.dtx
+++ b/l3trial/l3color-extras/l3color-extras.dtx
@@ -651,7 +651,7 @@
{
\@@_finalise:N \l__color_current_tl
\tl_set_eq:cN { l_@@_named_ . _tl } \l__color_current_tl
- \__driver_color_select:
+ \__driver_color_select:V \l__color_current_tl
}
\cs_new_protected:Npn \@@_finalise:N #1
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the latex3-commits
mailing list