[latex3-commits] [git/LaTeX3-latex3-latex3] icc2: Add \color_iccprofile_apply:nn (d996927c4)
Joseph Wright
joseph.wright at morningstar2.co.uk
Mon Oct 18 14:20:07 CEST 2021
Repository : https://github.com/latex3/latex3
On branch : icc2
Link : https://github.com/latex3/latex3/commit/d996927c45783c78a55bde519be2587e9457ac81
>---------------------------------------------------------------
commit d996927c45783c78a55bde519be2587e9457ac81
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Feb 23 15:07:56 2021 +0000
Add \color_iccprofile_apply:nn
No tests just yet.
>---------------------------------------------------------------
d996927c45783c78a55bde519be2587e9457ac81
l3backend/l3backend-color.dtx | 31 +++++++++++++++++++++++++
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3color.dtx | 53 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+)
diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index 12f43895d..24074441f 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -1041,6 +1041,37 @@
% \end{macrocode}
% \end{macro}
+%
+% \begin{macro}{\@@_backend_iccbased_device:nnn}
+% This is very similar to setting up a color space: the only part we
+% skip is adding it to the page resources.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_iccbased_device:nnn #1#2#3
+ {
+ \pdf_object_if_exist:nF { @@_icc_ #1 }
+ {
+ \pdf_object_new:nn { @@_icc_ #1 } { fstream }
+ \pdf_object_write:nn { @@_icc_ #1 }
+ {
+ { /N ~ #3 }
+ {#1}
+ }
+ }
+ \pdf_object_unnamed_write:nx { array }
+ { /ICCBased ~ \pdf_object_ref:n { @@_icc_ #1 } }
+ \cs_if_exist:NT \pdfmanagement_add:nnn
+ {
+ \use:x
+ {
+ \pdfmanagement_add:nnn
+ { Page / Resources / ColorSpace }
+ { Default #2 }
+ { \pdf_object_ref_last: }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
%</dvipdfmx|luatex|pdftex|xetex>
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 57c31221d..c0eb56e45 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
### Added
- Support for ICC-based color profiles
+- `\color_iccprofile_apply:nn`
## [2021-10-17]
diff --git a/l3kernel/l3color.dtx b/l3kernel/l3color.dtx
index 92dc61eca..40af3fc4f 100644
--- a/l3kernel/l3color.dtx
+++ b/l3kernel/l3color.dtx
@@ -442,6 +442,23 @@
% \item \texttt{file} The name of the file containing the profile.
% \end{itemize}
%
+% \subection{Color profiles}
+%
+% Color profiles are used to ensure color accuracy by linking to collaboration.
+% Applying a profile can be used to standardise color which is otherwise
+% device-dependence.
+%
+% \begin{function}[added = 2020-02-23]{\color_iccprofile_apply:nn}
+% \begin{syntax}
+% \cs{color_iccprofile_apply:nn} \Arg{profile} \Arg{model}
+% \end{syntax}
+% This function applies a \meta{profile} to one of the device \meta{models}.
+% The profile will then apply to all color of the selected \meta{model}. The
+% \meta{profile} should specify an ICC profile file. The \meta{model} has to
+% be one the standard device models: \texttt{cmyk}, \texttt{gray} or
+% \texttt{rgb}.
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -2596,6 +2613,42 @@
% \end{macro}
% \end{macro}
%
+% \subsection{Applying profiles}
+%
+% \begin{macro}{\color_iccprofile_apply:nn, \@@_iccprofile_apply:nn}
+% \begin{macro}
+% {
+% \@@_iccprofile_apply_gray:n ,
+% \@@_iccprofile_apply_rgb:n ,
+% \@@_iccprofile_apply_cmyk:n
+% }
+% With a limited range of outcomes, this is largely about getting data to the
+% backend.
+% \begin{macrocode}
+\cs_new_protected:Npn \color_iccprofile_apply:nn #1#2
+ {
+ \exp_args:Ne \@@_iccprofile_apply:nn
+ { \file_full_name:n {#1} } {#2}
+ }
+\cs_new_protected:Npn \@@_iccprofile_apply:nn #1#2
+ {
+ \cs_if_exist_use:cF { @@_iccprofile_apply_ \tl_to_str:n {#2} :n }
+ {
+ \msg_error:nnn { color } { ICC-Device-unknown } {#2}
+ \use_none:n
+ }
+ {#1}
+ }
+\cs_new_protected:Npn \@@_iccprofile_apply_gray:n #1
+ { \@@_backend_iccbased_device:nnn {#1} { Gray } { 1 } }
+\cs_new_protected:Npn \@@_iccprofile_apply_rgb:n #1
+ { \@@_backend_iccbased_device:nnn {#1} { RGB } { 3 } }
+\cs_new_protected:Npn \@@_iccprofile_apply_cmyk:n #1
+ { \@@_backend_iccbased_device:nnn {#1} { CMYK } { 4 } }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Diagnostics}
%
% \begin{macro}{\color_show:n, \color_log:n, \@@_show:Nn}
More information about the latex3-commits
mailing list.