[latex3-commits] [git/LaTeX3-latex3-graphics-def] develop: Add support for new dvidpfmx color stacks (05ddb30)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Jan 8 12:02:52 CET 2021


Repository : https://github.com/latex3/graphics-def
On branch  : develop
Link       : https://github.com/latex3/graphics-def/commit/05ddb3049a1c320028b92b49094243043192f706

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

commit 05ddb3049a1c320028b92b49094243043192f706
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Jan 8 11:02:52 2021 +0000

    Add support for new dvidpfmx color stacks


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

05ddb3049a1c320028b92b49094243043192f706
 dvipdfmx.def | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xetex.def    | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+)

diff --git a/dvipdfmx.def b/dvipdfmx.def
index 0944ae0..74d472e 100644
--- a/dvipdfmx.def
+++ b/dvipdfmx.def
@@ -336,3 +336,63 @@
 }
 \fi
 \fi
+% Updates for newer dvipdfmx versions
+% Loaded last as we can then bail-out if not required
+\begingroup
+  \immediate\openin 0 = |"extractbb --version"
+  \ifeof0 %
+    \def\extractbbversion{0}%
+  \else
+    \read0 to \extractbbversion % \par
+    \ifeof0 %
+      \def\extractbbversion{0}%
+    \else
+      \read0 to \extractbbversion
+        \long\def\getextractbbversion#1Version #2 #3\stop{%
+          \def\extractbbversion{#2}}%
+        \expandafter\getextractbbversion\extractbbversion Version 0 \stop
+    \fi
+  \fi
+\ifnum\extractbbversion<20201111 %
+  \endgroup
+  \expandafter\endinput
+\else
+  \endgroup
+\fi
+% Conversion functions so the internal representation stays unchanged
+\let\init at current@color\current at color
+\def\convert at color#1{%
+  \ifx#1\init at current@color
+    \expandafter\convert at color@init
+  \else
+    \expandafter\convert@@color
+  \fi
+    #1%
+}
+\def\convert at color@init#1{0 g 0 G}
+\def\convert@@color#1{%
+  \expandafter\convert@@@color#1\stop
+}
+\def\convert@@@color#1 #2\stop{%
+  \csname convert at color@#1\endcsname{#2}%
+}
+\def\convert at color@cmyk#1{#1 k #1 K}
+\def\convert at color@gray#1{#1 g #1 G}
+\def\convert at color@rgb#1{#1 rg #1 RG}
+% Change the specials to use the stack
+\chardef\main at pdfcolorstack=1 %
+\ifx\AtBeginDvi\undefined
+  \long\def\@firstofone#1{#1}%
+  \expandafter\@firstofone
+\else
+  \expandafter\AtBeginDvi
+\fi
+  {\special{pdfcolorstackinit \the\main at pdfcolorstack\space page direct (0 g 0 G)}}
+\def\@pdfcolorstack{\the\main at pdfcolorstack\space}
+\def\set at color{%
+  \special{pdfcolorstack \@pdfcolorstack push (\convert at color\current at color)}%
+  \aftergroup \reset at color
+}
+\def\reset at color{%
+  \special{pdfcolorstack \@pdfcolorstack pop}%
+}
diff --git a/xetex.def b/xetex.def
index 5364b6c..68ce574 100644
--- a/xetex.def
+++ b/xetex.def
@@ -435,3 +435,63 @@
 }
 \fi
 \fi
+% Updates for newer dvipdfmx versions
+% Loaded last as we can then bail-out if not required
+\begingroup
+  \immediate\openin 0 = |"extractbb --version"
+  \ifeof0 %
+    \def\extractbbversion{0}%
+  \else
+    \read0 to \extractbbversion % \par
+    \ifeof0 %
+      \def\extractbbversion{0}%
+    \else
+      \read0 to \extractbbversion
+        \long\def\getextractbbversion#1Version #2 #3\stop{%
+          \def\extractbbversion{#2}}%
+        \expandafter\getextractbbversion\extractbbversion Version 0 \stop
+    \fi
+  \fi
+\ifnum\extractbbversion<20201111 %
+  \endgroup
+  \expandafter\endinput
+\else
+  \endgroup
+\fi
+% Conversion functions so the internal representation stays unchanged
+\let\init at current@color\current at color
+\def\convert at color#1{%
+  \ifx#1\init at current@color
+    \expandafter\convert at color@init
+  \else
+    \expandafter\convert@@color
+  \fi
+    #1%
+}
+\def\convert at color@init#1{0 g 0 G}
+\def\convert@@color#1{%
+  \expandafter\convert@@@color#1\stop
+}
+\def\convert@@@color#1 #2\stop{%
+  \csname convert at color@#1\endcsname{#2}%
+}
+\def\convert at color@cmyk#1{#1 k #1 K}
+\def\convert at color@gray#1{#1 g #1 G}
+\def\convert at color@rgb#1{#1 rg #1 RG}
+% Change the specials to use the stack
+\chardef\main at pdfcolorstack=1 %
+\ifx\AtBeginDvi\undefined
+  \long\def\@firstofone#1{#1}%
+  \expandafter\@firstofone
+\else
+  \expandafter\AtBeginDvi
+\fi
+  {\special{pdfcolorstackinit \the\main at pdfcolorstack\space page direct (0 g 0 G)}}
+\def\@pdfcolorstack{\the\main at pdfcolorstack\space}
+\def\set at color{%
+  \special{pdfcolorstack \@pdfcolorstack push (\convert at color\current at color)}%
+  \aftergroup \reset at color
+}
+\def\reset at color{%
+  \special{pdfcolorstack \@pdfcolorstack pop}%
+}





More information about the latex3-commits mailing list.