[latex3-commits] [git/LaTeX3-latex3-latex3] master: First attempt at separations in dvips (82b102d95)
Joseph Wright
joseph.wright at morningstar2.co.uk
Wed Aug 26 21:47:58 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/82b102d95e02e4034a9a8d4386d11af572cfdc57
>---------------------------------------------------------------
commit 82b102d95e02e4034a9a8d4386d11af572cfdc57
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Aug 26 20:47:58 2020 +0100
First attempt at separations in dvips
>---------------------------------------------------------------
82b102d95e02e4034a9a8d4386d11af572cfdc57
l3backend/CHANGELOG.md | 3 +
l3backend/l3backend-color.dtx | 147 ++++++++++++++++++++++++++++++++++++-
l3backend/l3backend-header.dtx | 10 +++
l3experimental/CHANGELOG.md | 3 +
l3experimental/l3color/l3color.dtx | 73 ++----------------
5 files changed, 167 insertions(+), 69 deletions(-)
diff --git a/l3backend/CHANGELOG.md b/l3backend/CHANGELOG.md
index 6d9dbaab1..5bedb000a 100644
--- a/l3backend/CHANGELOG.md
+++ b/l3backend/CHANGELOG.md
@@ -6,6 +6,9 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Changed
+- Improved support for Separation colors
+
## [2020-08-07]
### Changed
diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index 28c940c89..e1cedec6e 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -258,6 +258,18 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}
+% {\@@_backend_separation_init:nnnnn, \@@_backend_separation_init_cielab:nnnnn}
+% \begin{macro}{\@@_backend_separation_init_cielab:n}
+% No support at present.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5 { }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:nnnnn #1#2#3#4#5 { }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:n #1 { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macrocode}
%</dvipdmx|xdvipdfmx>
% \end{macrocode}
@@ -273,6 +285,62 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_backend_separation_init:nnnnn}
+% \begin{macro}{\@@_backend_separation_init:nnn}
+% \begin{macro}[EXP]{\@@_backend_separation_init:n}
+% \begin{macro}[EXP]{\@@_backend_separation_init:w}
+% \begin{macro}{\@@_backend_separation_init_cielab:nnnnn}
+% \begin{macro}{\@@_backend_separation_init_cielab:n}
+% Initialising here means creating a small header set up plus massaging
+% some data. This comes about as we have to deal with PDF-focussed data,
+% which makes most sense \enquote{higher-up}.
+% \begin{macrocode}
+\cs_new_protected:Npx \@@_backend_separation_init:nnnnn #1#2#3#4#5
+ {
+ \bool_if:NT \g__kernel_backend_header_bool
+ {
+ \cs_if_exist:NTF \AtBeginDvi
+ { \AtBeginDvi }
+ { \use:n }
+ {
+ \exp_not:N \exp_args:Nxx
+ \exp_not:N \@@_backend_separation_init:nnn
+ { \str_convert_pdfname:n {#1} } { } {#5}
+ }
+ }
+ }
+\cs_new_protected:Npn \@@_backend_separation_init:nnn #1#2#3
+ {
+ \__kernel_backend_literal:e
+ {
+ !
+ TeXDict ~ begin ~
+ / #1 ~ [#3] ~ aload ~ pop ~ (#1) ~
+ find \@@_backend__separation_init:n {#2} customcolor ~ def ~
+ end
+ }
+ }
+\cs_new:Npx \@@_backend__separation_init:n #1
+ {
+ \exp_not:N \@@_backend__separation_init:w
+ #1 \tl_to_str:n { /Device } #1 \tl_to_str:n { /Device }
+ \exp_not:N \s_@@_stop
+ }
+\cs_new:Npn \@@_backend__separation_init:w #1 /Device #2 /Device #3 \s_@@_stop
+ { \str_lowercase:n {#2} }
+% \end{macrocode}
+% Currently no CIELAB support.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:nnnnn #1#2#3#4#5 { }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:n #1 { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macrocode}
%</dvips>
% \end{macrocode}
@@ -288,6 +356,18 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}
+% {\@@_backend_separation_init:nnnnn, \@@_backend_separation_init_cielab:nnnnn}
+% \begin{macro}{\@@_backend_separation_init_cielab:n}
+% No support at present.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5 { }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:nnnnn #1#2#3#4#5 { }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:n #1 { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macrocode}
%</dvisvgm>
% \end{macrocode}
@@ -303,10 +383,75 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}
+% {\@@_backend_separation_init:nnnnn, \@@_backend_separation_init_cielab:nnnnn}
+% \begin{macro}{\@@_backend_separation_init_cielab:n}
+% Initialising the PDF structures needs two parts: creating an object
+% containing the \enquote{real} name of the Separation, then adding a reference
+% to that to each page. The latter uses the internal name of the \texttt{cs}.
% \begin{macrocode}
-%</pdfmode>
+\cs_new_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5
+ {
+ \pdf_object_now:nx { array }
+ {
+ /Separation
+ / \str_convert_pdfname:n {#1} ~ #2 ~
+ <<
+ /FunctionType ~ 2
+ /Domain ~ [0 ~ 1]
+ \tl_if_blank:nF {#3} { /Range ~ [#3] }
+ /C0 ~ [#4] ~
+ /C1 ~ [#5] /N ~ 1
+ >>
+ }
+ \use:x
+ {
+ \pdfcoredict_gput:nnn
+ { Page / Resources / ColorSpace }
+ { color \int_use:N \g_@@_separation_int }
+ { \pdf_object_last: }
+ }
+ }
+\cs_if_exist:NF \pdf_object_now:nn
+ { \cs_gset_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5 { } }
+% \end{macrocode}
+% For CIELAB colors, we need one object per document for the illuminant,
+% plus initialisation of the color space referencing that object.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:nnnnn #1#2#3#4#5
+ {
+ \@@_backend_separation_init:nnnnn
+ {#2}
+ { \pdf_object_ref:n { @@_illuminant_cielab_ #1 } }
+ { \c_@@_model_range_lab_tl }
+ { 100 ~ 0 ~ 0 }
+ { #3 ~ #4 ~ #5 }
+ }
+\cs_if_exist:NF \pdf_object_now:nn
+ { \cs_gset_protected:Npn \@@_backend_separation_init_cielab:nnnnn #1#2#3#4#5 { } }
+\cs_new_protected:Npn \@@_backend_separation_init_cielab:n #1
+ {
+ \pdf_object_new:nn { @@_illuminant_cielab_ #1 } { array }
+ \pdf_object_write:nx { @@_illuminant_cielab_ #1 }
+ {
+ /Lab ~
+ <<
+ /WhitePoint ~
+ [ \tl_use:c { c_@@_model_whitepoint_cielab_ #1 _tl } ]
+ /Range ~ [ \c_@@_model_range_lab_tl ]
+ >>
+ }
+ }
+\cs_if_exist:NF \pdf_object_new:nn
+ { \cs_gset_protected:Npn \@@_backend_separation_init_cielab:n #1 { } }
% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
+% \begin{macrocode}
+%</pdfmode>
+% \end{macrocode}
%
% \subsection{Fill and stroke color}
%
diff --git a/l3backend/l3backend-header.dtx b/l3backend/l3backend-header.dtx
index 24e7ee2cf..99c27e223 100644
--- a/l3backend/l3backend-header.dtx
+++ b/l3backend/l3backend-header.dtx
@@ -67,6 +67,16 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{TeXcolorsetspotcolor, setspotcolor}
+% Support for separation/spot colors: this strange naming is so
+% things work with the color stack.
+% \begin{macrocode}
+TeXDict begin
+/TeXcolorsetspotcolor { setcustomcolor } def
+end
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{pdf.globaldict}
% A small global dictionary for backend use.
% \begin{macrocode}
diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index 5a1c06dee..8efd7027d 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -12,6 +12,9 @@ this project uses date-based 'snapshot' version identifiers.
- Support for `hsb` color model
- Support for `wave` color model
+### Changed
+- Better support for color separations
+
### Fixed
- Integer range for `HSB` color model
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 90cefe191..56d0a31a3 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -1566,9 +1566,6 @@
% \begin{macro}{\@@_model_convert:nnn}
% \begin{macro}{\@@_model_separation_cielab:nnnnnn}
% \begin{macro}{\@@_model_separation_cielab:nnnnnnn}
-% \begin{macro}{\@@_model_separation_init:nnnnn}
-% \begin{macro}{\@@_model_separation_init_cielab:n}
-% \begin{macro}{\@@_model_separation_init_cielab:nnnnn}
% Set up a new model: in general this has to be handled by a family-dependent
% function. To avoid some \enquote{interesting} questions with casing, we
% fold the case of the family name. The key--value list should always be
@@ -1699,7 +1696,7 @@
}
\@@_model_convert:nnn {#1} { cmyk } { rgb }
\@@_model_convert:nnn {#1} { cmyk } { gray }
- \@@_model_separation_init:nnnnn {#2} { /DeviceCMYK } { }
+ \@@_backend_separation_init:nnnnn {#2} { /DeviceCMYK } { }
{ 0 ~ 0 ~ 0 ~ 0 } { #3 ~ #4 ~ #5 ~ #6 }
}
\cs_new_protected:Npn \@@_model_separation_rgb:nnnnnn #1#2#3#4#5#6
@@ -1712,7 +1709,7 @@
}
\@@_model_convert:nnn {#1} { rgb } { cmyk }
\@@_model_convert:nnn {#1} { rgb } { gray }
- \@@_model_separation_init:nnnnn {#2} { /DeviceRGB } { }
+ \@@_backend_separation_init:nnnnn {#2} { /DeviceRGB } { }
{ 0 ~ 0 ~ 0 } { #3 ~ #4 ~ #5 }
}
\cs_new_protected:Npn \@@_model_separation_gray:nnnnnn #1#2#3#4#5#6
@@ -1732,7 +1729,7 @@
\fp_eval:n {##1 * #3} ~
\fp_eval:n {##1 * #3}
}
- \@@_model_separation_init:nnnnn {#2} { /DeviceGray } { } { 0 } {#3}
+ \@@_backend_separation_init:nnnnn {#2} { /DeviceGray } { } { 0 } {#3}
}
% \end{macrocode}
% Generic model conversion \emph{via} an alternative intermediate.
@@ -1774,8 +1771,8 @@
{
\tl_if_exist:cTF { c_@@_model_whitepoint_cielab_ #1 _tl }
{
- \@@_model_separation_init_cielab:n {#1}
- \@@_model_separation_init_cielab:nnnnn {#2} {#3} {#4} {#5} {#6}
+ \@@_backend_separation_init_cielab:n {#1}
+ \@@_backend_separation_init_cielab:nnnnn {#2} {#3} {#4} {#5} {#6}
\cs_new:cpn { @@_convert_ #2 _cmyk:w } ##1 ~ ##2 \s_@@_stop
{ 0 ~ 0 ~ 0 ~ 1 }
\cs_new:cpn { @@_convert_ #2 _rgb:w } ##1 ~ ##2 \s_@@_stop
@@ -1789,66 +1786,6 @@
}
}
% \end{macrocode}
-% Initialising the PDF structures needs two parts: creating an object
-% containing the \enquote{real} name of the Separation, then adding a reference
-% to that to each page. The latter uses the internal name of the \texttt{cs}.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_model_separation_init:nnnnn #1#2#3#4#5
- {
- \pdf_object_now:nx { array }
- {
- /Separation
- / \str_convert_pdfname:n {#1} ~ #2 ~
- <<
- /FunctionType ~ 2
- /Domain ~ [0 ~ 1]
- \tl_if_blank:nF {#3} { /Range ~ [#3] }
- /C0 ~ [#4] ~
- /C1 ~ [#5] /N ~ 1
- >>
- }
- \use:x
- {
- \pdfcoredict_gput:nnn
- { Page / Resources / ColorSpace }
- { color \int_use:N \g_@@_separation_int }
- { \pdf_object_last: }
- }
- }
-\cs_if_exist:NF \pdf_object_now:nn
- { \cs_gset_protected:Npn \@@_model_separation_init:nnnnn #1#2#3#4#5 { } }
-% \end{macrocode}
-% For CIELAB colors, we need one object per document for the illuminant,
-% plus initialisation of the color space referencing that object.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_model_separation_init_cielab:n #1
- {
- \pdf_object_new:nn { @@_illuminant_cielab_ #1 } { array }
- \pdf_object_write:nx { @@_illuminant_cielab_ #1 }
- {
- /Lab ~
- <<
- /WhitePoint ~
- [ \tl_use:c { c_@@_model_whitepoint_cielab_ #1 _tl } ]
- /Range ~ [ \c_@@_model_range_lab_tl ]
- >>
- }
- }
-\cs_if_exist:NF \pdf_object_new:nn
- { \cs_gset_protected:Npn \@@_model_separation_init_cielab:n #1 { } }
-\cs_new_protected:Npn \@@_model_separation_init_cielab:nnnnn #1#2#3#4#5
- {
- \@@_model_separation_init:nnnnn
- {#2}
- { \pdf_object_ref:n { @@_illuminant_cielab_ #1 } }
- { \c_@@_model_range_lab_tl }
- { 100 ~ 0 ~ 0 }
- { #3 ~ #4 ~ #5 }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
More information about the latex3-commits
mailing list.