[latex3-commits] [git/LaTeX3-latex3-latex3] master: Use same color stack approach in (x)dvipdfmx and pdfTeX (ca3fe9cbd)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Dec 8 15:27:49 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/ca3fe9cbde4b81bee7a851cfb54515b44c1bfe64

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

commit ca3fe9cbde4b81bee7a851cfb54515b44c1bfe64
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Dec 8 14:24:59 2020 +0000

    Use same color stack approach in (x)dvipdfmx and pdfTeX
    
    Only changes the stacked colors at present.


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

ca3fe9cbde4b81bee7a851cfb54515b44c1bfe64
 l3backend/CHANGELOG.md                   |  4 ++
 l3backend/l3backend-color.dtx            | 71 +++++++++++---------------------
 l3kernel/testfiles/d3dvipdfmx.luatex.tlg |  1 +
 l3kernel/testfiles/d3dvipdfmx.tlg        |  1 +
 l3kernel/testfiles/d3dvipdfmx.xetex.tlg  |  1 +
 l3kernel/testfiles/d3dvips.xetex.tlg     |  1 +
 l3kernel/testfiles/d3pdfmode.xetex.tlg   |  1 +
 l3kernel/testfiles/d3xetex.xetex.tlg     |  1 +
 l3kernel/testfiles/m3expl001.xetex.tlg   |  4 +-
 l3kernel/testfiles/m3expl002.xetex.tlg   |  1 +
 l3kernel/testfiles/m3expl003.xetex.tlg   |  4 +-
 l3kernel/testfiles/m3expl004.xetex.tlg   |  1 +
 l3kernel/testfiles/m3expl006.xetex.tlg   |  1 +
 l3kernel/testfiles/m3expl007.xetex.tlg   |  1 +
 14 files changed, 43 insertions(+), 50 deletions(-)

diff --git a/l3backend/CHANGELOG.md b/l3backend/CHANGELOG.md
index 54a32b1de..ef88d482a 100644
--- a/l3backend/CHANGELOG.md
+++ b/l3backend/CHANGELOG.md
@@ -10,6 +10,10 @@ this project uses date-based 'snapshot' version identifiers.
 - Support for referencing last link with `(x)dvipdfmx` (requires an up-to-date
   backend)
 
+### Changed
+- Implementation of color wtih (x)dvipdfmx (requires an up-to-date
+  backend)
+
 ## [2020-09-24]
 
 ### Fixed
diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index ff0e3fd10..895c4e484 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -315,12 +315,12 @@
 % \subsubsection{\LuaTeX{} and \pdfTeX{}}
 %
 %    \begin{macrocode}
-%<*luatex|pdftex>
+%<*dvipdfmx|luatex|pdftex|xetex>
 %    \end{macrocode}
 %
 % \begin{variable}{\l__kernel_color_stack_int}
-%   \pdfTeX{} and \LuaTeX{} have multiple stacks available, and to track
-%   which one is in use a variable is required.
+%   \pdfTeX{}, \LuaTeX{} and recent \texttt{(x)dvipdfmx} have multiple stacks
+%   available, and to track which one is in use a variable is required.
 %    \begin{macrocode}
 \int_new:N \l__kernel_color_stack_int
 %    \end{macrocode}
@@ -353,7 +353,7 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-%</luatex|pdftex>
+%</dvipdfmx|luatex|pdftex|xetex>
 %    \end{macrocode}
 %
 % \subsubsection{\texttt{dvipmdfx}/\XeTeX{}}
@@ -364,14 +364,11 @@
 %
 % These backends have the most possible approaches: it recognises both
 % \texttt{dvips}-based color specials and it's own format, plus one can
-% include PDF statements directly. The latter are not subject to the stack,
-% so are not suitable for general use. Of the two stack methods, the dedicated
-% one has been extended to cover color spaces, so it is used in preference to
-% the \texttt{dvips} one.
-%
-% The \LaTeXe{} backend code uses \texttt{dvips}-based code with
-% \texttt{dvipmdfx}/\XeTeX{}, and so we leave getting color from \LaTeXe{} to
-% a shared code path below.
+% include PDF statements directly. Recent releases also have a color stack
+% approach similar to \pdfTeX{}. Of the stack methods, the dedicated
+% the most versatile is the latter as it can cover all of the use cases
+% we have. Thus it is used in preference to the \texttt{dvips}-style interface
+% or the \enquote{native} color specials (which have only one stack).
 %
 % \begin{macro}
 %   {
@@ -382,15 +379,18 @@
 % \begin{macro}{\@@_backend_reset:}
 %    Push the data to the stack.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_select_cmyk:n #1
+\int_compare:nNnT \c__kernel_sys_dvipdfmx_version_int < { 20201111 }
   {
-    \__kernel_backend_literal:n { pdf: bc ~ [#1] }
-    \group_insert_after:N \@@_backend_reset:
+    \cs_gset_protected:Npn \@@_backend_select_cmyk:n #1
+      {
+        \__kernel_backend_literal:n { pdf: bc ~ [#1] }
+        \group_insert_after:N \@@_backend_reset:
+      }
+    \cs_gset_eq:NN \@@_backend_select_gray:n \@@_backend_select_cmyk:n
+    \cs_gset_eq:NN \@@_backend_select_rgb:n \@@_backend_select_cmyk:n
+    \cs_gset_protected:Npn \@@_backend_reset:
+      { \__kernel_backend_literal:n { pdf: ec } }
   }
-\cs_new_eq:NN \@@_backend_select_gray:n \@@_backend_select_cmyk:n
-\cs_new_eq:NN \@@_backend_select_rgb:n \@@_backend_select_cmyk:n
-\cs_new_protected:Npn \@@_backend_reset:
-  { \__kernel_backend_literal:n { pdf: ec } }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -701,22 +701,12 @@
 %
 % \begin{macro}{\@@_backend_select_separation:nn, \@@_backend_select_devicen:nn}
 % \begin{macro}{\@@_backend_select:n}
-%   Different syntaxes here as the stacks are accessed very differently.
+%   Although \texttt{(x)dvipdfmx} has a built-in approach to color spaces, that
+%   can't be used with the generic color stacks. So we take an approach in which
+%   we share the same code as for \pdfTeX{}.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_select_separation:nn #1#2
-%<*dvipdfmx|xetex>
-  { \@@_backend_select:n { @#1 ~ [#2] } }
-%</dvipdfmx|xetex>
-%<*luatex|pdftex>
   { \@@_backend_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ scn ~ #2 ~ SCN } }
-%</luatex|pdftex>
-%<*dvipdfmx|xetex>
-\cs_new_protected:Npn \@@_backend_select:n #1
-  {
-    \__kernel_backend_literal:n { pdf: bc ~ #1 }
-    \group_insert_after:N \@@_backend_reset:
-  }
-%</dvipdfmx|xetex>
 \cs_new_eq:NN \@@_backend_select_devicen:nn \@@_backend_select_separation:nn
 %    \end{macrocode}
 % \end{macro}
@@ -727,9 +717,7 @@
 % \begin{macro}{\@@_backend_separation_init_CIELAB:nnn}
 %   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}.
-%   For \texttt{dvipdfmx}/\XeTeX{}, the backend does most of the work so we need a
-%   simplified version. We use a separate object for the tint transformation
+%   to that to each page. We use a separate object for the tint transformation
 %   following the model in the PDF reference.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5
@@ -748,7 +736,6 @@
         / \str_convert_pdfname:n {#1} ~ #2 ~
         \pdf_object_last:
       }
-%<*luatex|pdftex>
     \use:x
       {
         \pdfcoredict_gput:nnn
@@ -756,22 +743,12 @@
           { color \int_use:N \g_@@_model_int }
           { \pdf_object_last: }
       }
-%</luatex|pdftex>
   }
 \cs_if_exist:NF \pdf_object_now:nn
   { \cs_gset_protected:Npn \@@_backend_separation_init:nnnnn #1#2#3#4#5 { } }
 \cs_new_protected:Npn \@@_backend_separation_init:n #1
   {
-%<*dvipdfmx|xetex>
-    \__kernel_backend_literal:x
-      {
-        pdf:obj ~ @color \int_use:N \g_@@_model_int \c_space_tl
-          [#1]
-      }
-%</dvipdfmx|xetex>
-%<*luatex|pdftex>
     \pdf_object_now:nx { array } {#1}
-%</luatex|pdftex>  
   }
 %    \end{macrocode}
 %   For CIELAB colors, we need one object per document for the illuminant,
@@ -846,7 +823,6 @@
         #2 ~
         \pdf_object_last:
       }
-%<*luatex|pdftex>
     \use:x
       {
         \pdfcoredict_gput:nnn
@@ -854,7 +830,6 @@
           { color \int_use:N \g_@@_model_int }
           { \pdf_object_last: }
       }
-%</luatex|pdftex>
   }
 \cs_if_exist:NF \pdf_object_now:nn
   { \cs_gset_protected:Npn \@@_backend_devicen_init:nnn #1#2#3 { } }
diff --git a/l3kernel/testfiles/d3dvipdfmx.luatex.tlg b/l3kernel/testfiles/d3dvipdfmx.luatex.tlg
index 5d19443fe..a0d4b0a52 100644
--- a/l3kernel/testfiles/d3dvipdfmx.luatex.tlg
+++ b/l3kernel/testfiles/d3dvipdfmx.luatex.tlg
@@ -8,6 +8,7 @@ File: l3debug.def ....-..-.. L3 Debugging support
 File: l3backend-dvipdfmx.def ....-..-.. L3 backend support: dvipdfmx
 ("|extractbb --version")
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/d3dvipdfmx.tlg b/l3kernel/testfiles/d3dvipdfmx.tlg
index 626af9a73..785ddd42b 100644
--- a/l3kernel/testfiles/d3dvipdfmx.tlg
+++ b/l3kernel/testfiles/d3dvipdfmx.tlg
@@ -8,6 +8,7 @@ File: l3debug.def ....-..-.. L3 Debugging support
 File: l3backend-dvipdfmx.def ....-..-.. L3 backend support: dvipdfmx
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/d3dvipdfmx.xetex.tlg b/l3kernel/testfiles/d3dvipdfmx.xetex.tlg
index 5fe1f8268..e3b681de2 100644
--- a/l3kernel/testfiles/d3dvipdfmx.xetex.tlg
+++ b/l3kernel/testfiles/d3dvipdfmx.xetex.tlg
@@ -16,6 +16,7 @@ the active engine. LaTeX3 will use the 'xetex' backend instead.
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/d3dvips.xetex.tlg b/l3kernel/testfiles/d3dvips.xetex.tlg
index d434283c4..9ffbad24f 100644
--- a/l3kernel/testfiles/d3dvips.xetex.tlg
+++ b/l3kernel/testfiles/d3dvips.xetex.tlg
@@ -16,6 +16,7 @@ active engine. LaTeX3 will use the 'xetex' backend instead.
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/d3pdfmode.xetex.tlg b/l3kernel/testfiles/d3pdfmode.xetex.tlg
index 8ed522d3b..04ee15a70 100644
--- a/l3kernel/testfiles/d3pdfmode.xetex.tlg
+++ b/l3kernel/testfiles/d3pdfmode.xetex.tlg
@@ -16,6 +16,7 @@ the active engine. LaTeX3 will use the 'xetex' backend instead.
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/d3xetex.xetex.tlg b/l3kernel/testfiles/d3xetex.xetex.tlg
index 9fe7a9a6b..47e15fd90 100644
--- a/l3kernel/testfiles/d3xetex.xetex.tlg
+++ b/l3kernel/testfiles/d3xetex.xetex.tlg
@@ -8,6 +8,7 @@ File: l3debug.def ....-..-.. L3 Debugging support
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 9caa418e5..ce0a75368 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -29,12 +29,14 @@ Defining \__kernel_backend_scope_end: on line ...
 Defining \c__kernel_sys_dvipdfmx_version_int on line ...
 \c__kernel_sys_dvipdfmx_version_int=\count...
 Defining \__color_backend_pickup:N on line ...
+Defining \l__kernel_color_stack_int on line ...
+\l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_rgb:n on line ...
+Defining \__color_backend_select:n on line ...
 Defining \__color_backend_reset: on line ...
 Defining \__color_backend_select_separation:nn on line ...
-Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select_devicen:nn on line ...
 Defining \__color_backend_separation_init:nnnnn on line ...
 Defining \__color_backend_separation_init:n on line ...
diff --git a/l3kernel/testfiles/m3expl002.xetex.tlg b/l3kernel/testfiles/m3expl002.xetex.tlg
index 8fcbd1911..c64be0624 100644
--- a/l3kernel/testfiles/m3expl002.xetex.tlg
+++ b/l3kernel/testfiles/m3expl002.xetex.tlg
@@ -8,6 +8,7 @@ File: l3debug.def ....-..-.. L3 Debugging support
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 9caa418e5..ce0a75368 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -29,12 +29,14 @@ Defining \__kernel_backend_scope_end: on line ...
 Defining \c__kernel_sys_dvipdfmx_version_int on line ...
 \c__kernel_sys_dvipdfmx_version_int=\count...
 Defining \__color_backend_pickup:N on line ...
+Defining \l__kernel_color_stack_int on line ...
+\l__kernel_color_stack_int=\count...
 Defining \__color_backend_select_cmyk:n on line ...
 Defining \__color_backend_select_gray:n on line ...
 Defining \__color_backend_select_rgb:n on line ...
+Defining \__color_backend_select:n on line ...
 Defining \__color_backend_reset: on line ...
 Defining \__color_backend_select_separation:nn on line ...
-Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select_devicen:nn on line ...
 Defining \__color_backend_separation_init:nnnnn on line ...
 Defining \__color_backend_separation_init:n on line ...
diff --git a/l3kernel/testfiles/m3expl004.xetex.tlg b/l3kernel/testfiles/m3expl004.xetex.tlg
index 384ac3ba3..676268850 100644
--- a/l3kernel/testfiles/m3expl004.xetex.tlg
+++ b/l3kernel/testfiles/m3expl004.xetex.tlg
@@ -6,6 +6,7 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/m3expl006.xetex.tlg b/l3kernel/testfiles/m3expl006.xetex.tlg
index 6da8c2d2f..3ca66867f 100644
--- a/l3kernel/testfiles/m3expl006.xetex.tlg
+++ b/l3kernel/testfiles/m3expl006.xetex.tlg
@@ -7,6 +7,7 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...
diff --git a/l3kernel/testfiles/m3expl007.xetex.tlg b/l3kernel/testfiles/m3expl007.xetex.tlg
index 2931d3ceb..d615906cc 100644
--- a/l3kernel/testfiles/m3expl007.xetex.tlg
+++ b/l3kernel/testfiles/m3expl007.xetex.tlg
@@ -7,6 +7,7 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
 File: l3backend-xetex.def ....-..-.. L3 backend support: XeTeX
 (|extractbb --version)
 \c__kernel_sys_dvipdfmx_version_int=\count...
+\l__kernel_color_stack_int=\count...
 \g__graphics_track_int=\count...
 \l__pdf_internal_box=\box...
 \g__pdf_backend_object_int=\count...





More information about the latex3-commits mailing list.