[latex3-commits] [git/LaTeX3-latex3-latex3] icc2: Add \color_iccprofile_apply:nn (ca6f9a552)

Marcel Fabian Krüger tex at 2krueger.de
Thu Oct 14 15:08:51 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : icc2
Link       : https://github.com/latex3/latex3/commit/ca6f9a55268eead552c2ab9889f7d53f53c0f86e

>---------------------------------------------------------------

commit ca6f9a55268eead552c2ab9889f7d53f53c0f86e
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.


>---------------------------------------------------------------

ca6f9a55268eead552c2ab9889f7d53f53c0f86e
 l3backend/l3backend-color.dtx | 31 +++++++++++++++++++++++++
 l3kernel/CHANGELOG.md         |  3 +++
 l3kernel/l3color.dtx          | 53 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index 72254382f..366cc65ad 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -926,6 +926,37 @@
 % \end{macro}
 % \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>
 %    \end{macrocode}
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 55e9db4bb..65133d487 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+- `\color_iccprofile_apply:nn`
+
 ## [2021-10-12]
 
 ### Fixed
diff --git a/l3kernel/l3color.dtx b/l3kernel/l3color.dtx
index 36fa14876..8735cf12b 100644
--- a/l3kernel/l3color.dtx
+++ b/l3kernel/l3color.dtx
@@ -436,6 +436,23 @@
 %   a process color name (\texttt{cyan}, etc.) or the special name \texttt{none}.
 % \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}
@@ -2513,6 +2530,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.