[latex3-commits] [git/LaTeX3-latex3-latex3] main: Allow for backend loading before l3graphics (9972f03b2)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Apr 6 13:57:24 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/9972f03b2d40faf0e82cb5ca3ffc76701e35ea4a

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

commit 9972f03b2d40faf0e82cb5ca3ffc76701e35ea4a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Apr 6 12:56:55 2022 +0100

    Allow for backend loading before l3graphics
    
    This adds most of the extensions supported by the
    classical graphics package.


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

9972f03b2d40faf0e82cb5ca3ffc76701e35ea4a
 l3backend/CHANGELOG.md                   |   3 +
 l3backend/l3backend-graphics.dtx         | 126 ++++++++++++++++++++++++++-----
 l3experimental/l3graphics/l3graphics.dtx |   4 +-
 3 files changed, 113 insertions(+), 20 deletions(-)

diff --git a/l3backend/CHANGELOG.md b/l3backend/CHANGELOG.md
index 6e9e06ea4..174b4e0ae 100644
--- a/l3backend/CHANGELOG.md
+++ b/l3backend/CHANGELOG.md
@@ -6,6 +6,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Fixed
+- Setup for graphics extension searching
+
 ### Removed
 - Support for pre-2020-11-11 `dvipdfmx`
 
diff --git a/l3backend/l3backend-graphics.dtx b/l3backend/l3backend-graphics.dtx
index 19dfb14b1..25d22d0cf 100644
--- a/l3backend/l3backend-graphics.dtx
+++ b/l3backend/l3backend-graphics.dtx
@@ -60,20 +60,48 @@
 %<@@=graphics>
 %    \end{macrocode}
 %
+% \begin{macro}{\@@_backend_loaded:n}
+%   To deal with file load ordering. Plain users are on their own.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_loaded:n #1
+  {
+    \cs_if_exist:NTF \hook_gput_code:nnn
+      {
+        \hook_gput_code:nnn
+          { file / l3graphics.sty / after }
+          { backend }
+          {#1}
+      }
+      {#1}
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{\texttt{dvips} backend}
 %
 %    \begin{macrocode}
 %<*dvips>
 %    \end{macrocode}
 %
-% \begin{macro}{\@@_backend_getbb_eps:n}
+% \begin{variable}{\l_graphics_search_ext_seq}
+%    \begin{macrocode}
+\@@_backend_loaded:n
+  { \seq_set_from_clist:Nn \l_graphics_search_ext_seq { .eps , .ps } }
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\@@_backend_getbb_eps:n, \@@_backend_getbb_ps:n}
 %   Simply use the generic function.
 %    \begin{macrocode}
-\cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n
+\@@_backend_loaded:n
+  {
+    \cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n
+    \cs_new_eq:NN \@@_backend_getbb_ps:n \@@_read_bb:n
+  }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_backend_include_eps:n}
+% \begin{macro}{\@@_backend_include_eps:n, \@@_backend_include_ps:n}
 %  The special syntax is relatively clear here: remember we need PostScript
 %  sizes here.
 %    \begin{macrocode}
@@ -88,6 +116,7 @@
         ury = \dim_to_decimal_in_bp:n \l_@@_ury_dim
       }
   }
+\cs_new_eq:NN \@@_backend_include_ps:n \@@_backend_include_eps:n
 %    \end{macrocode}
 % \end{macro}
 %
@@ -101,6 +130,17 @@
 %<*luatex|pdftex>
 %    \end{macrocode}
 %
+% \begin{variable}{\l_graphics_search_ext_seq}
+%    \begin{macrocode}
+\@@_backend_loaded:n
+  {
+    \seq_set_from_clist:Nn
+      \l_graphics_search_ext_seq
+      { .pdf , .eps , .png , .jpg , .jpeg  }
+  }
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{variable}{\l_@@_graphics_attr_tl}
 %   In PDF mode, additional attributes of an graphic (such as page number) are
 %   needed both to obtain the bounding box and when inserting the graphic: this
@@ -115,8 +155,9 @@
 %
 % \begin{macro}
 %   {
-%     \@@_backend_getbb_jpg:n,
-%     \@@_backend_getbb_pdf:n,
+%     \@@_backend_getbb_jpg:n  ,
+%     \@@_backend_getbb_jpeg:n ,
+%     \@@_backend_getbb_pdf:n  ,
 %     \@@_backend_getbb_png:n
 %   }
 % \begin{macro}
@@ -142,6 +183,7 @@
     \tl_clear:N \l_@@_graphics_attr_tl
     \@@_backend_getbb_auxi:n {#1}
   }
+\cs_new_eq:NN \@@_backend_getbb_jpeg:n \@@_backend_getbb_jpg:n
 \cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n
 \cs_new_protected:Npn \@@_backend_getbb_pdf:n #1
   {
@@ -200,8 +242,9 @@
 %
 % \begin{macro}
 %   {
-%     \@@_backend_include_jpg:n,
-%     \@@_backend_include_pdf:n,
+%     \@@_backend_include_jpg:n  ,
+%     \@@_backend_include_jpeg:n ,
+%     \@@_backend_include_pdf:n  ,
 %     \@@_backend_include_png:n
 %   }
 %   Images are already loaded for the measurement part of the code, so
@@ -213,6 +256,7 @@
     \tex_pdfrefximage:D
       \int_use:c { c_@@_graphics_ #1 \l_@@_graphics_attr_tl _int }
   }
+\cs_new_eq:NN \@@_backend_include_jpeg:n \@@_backend_include_jpg:n
 \cs_new_eq:NN \@@_backend_include_pdf:n \@@_backend_include_jpg:n
 \cs_new_eq:NN \@@_backend_include_png:n \@@_backend_include_jpg:n
 %    \end{macrocode}
@@ -283,15 +327,31 @@
 %<*dvipdfmx|xetex>
 %    \end{macrocode}
 %
+% \begin{variable}{\l_graphics_search_ext_seq}
+%    \begin{macrocode}
+\@@_backend_loaded:n
+  {
+    \seq_set_from_clist:Nn \l_graphics_search_ext_seq
+      { .pdf , .eps , .ps , .png , .jpg ., jpeg , .bmp }
+   }
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}
 %   {
-%     \@@_backend_getbb_eps:n, \@@_backend_getbb_jpg:n,
-%     \@@_backend_getbb_pdf:n, \@@_backend_getbb_png:n
+%     \@@_backend_getbb_eps:n ,
+%     \@@_backend_getbb_jpg:n , \@@_backend_getbb_jpeg:n ,
+%     \@@_backend_getbb_pdf:n , \@@_backend_getbb_png:n  ,
+%     \@@_backend_getbb_bmp:n
 %   }
 %   Simply use the generic functions: only for \texttt{dvipdfmx} in the
 %   extraction cases.
 %    \begin{macrocode}
-\cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n
+\@@_backend_loaded:n
+  {
+    \cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n
+    \cs_new_eq:NN \@@_backend_getbb_ps:n \@@_read_bb:n
+  }
 %<*dvipdfmx>
 \cs_new_protected:Npn \@@_backend_getbb_jpg:n #1
   {
@@ -299,7 +359,9 @@
     \tl_clear:N \l_@@_pagebox_str
     \@@_extract_bb:n {#1}
   }
+\cs_new_eq:NN \@@_backend_getbb_jpeg:n \@@_backend_getbb_jpg:n
 \cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n
+\cs_new_eq:NN \@@_backend_getbb_bmp:n \@@_backend_getbb_jpg:n
 \cs_new_protected:Npn \@@_backend_getbb_pdf:n #1
   {
     \tl_clear:N \l_@@_decodearray_str
@@ -319,8 +381,10 @@
 %
 % \begin{macro}
 %   {
-%     \@@_backend_include_eps:n, \@@_backend_include_jpg:n,
-%     \@@_backend_include_pdf:n, \@@_backend_include_png:n
+%     \@@_backend_include_eps:n , \@@_backend_include_ps:n ,
+%     \@@_backend_include_jpg:n , \@@_backend_include_jpseg:n ,
+%     \@@_backend_include_pdf:n , \@@_backend_include_png:n ,
+%     \@@_backend_include_bmp:n ,
 %   }
 %  \begin{macro}{\@@_backend_include_auxi:nn}
 %  \begin{macro}{\@@_backend_include_auxii:nnn, \@@_backend_include_auxii:xnn}
@@ -341,9 +405,12 @@
         ury = \dim_to_decimal_in_bp:n \l_@@_ury_dim
       }
   }
+\cs_new_eq:NN \@@_backend_include_ps:n \@@_backend_include_eps:n
 \cs_new_protected:Npn \@@_backend_include_jpg:n #1
   { \@@_backend_include_auxi:nn {#1} { image } }
+\cs_new_eq:NN \@@_backend_include_jpeg:n \@@_backend_include_jpg:n
 \cs_new_eq:NN \@@_backend_include_png:n \@@_backend_include_jpg:n
+\cs_new_eq:NN \@@_backend_include_bmp:n \@@_backend_include_jpg:n
 %<*dvipdfmx>
 \cs_new_protected:Npn \@@_backend_include_pdf:n #1
   { \@@_backend_include_auxi:nn {#1} { epdf } }
@@ -438,9 +505,11 @@
 %
 % \begin{macro}
 %   {
-%     \@@_backend_getbb_jpg:n,
-%     \@@_backend_getbb_pdf:n,
-%     \@@_backend_getbb_png:n
+%     \@@_backend_getbb_jpg:n  ,
+%     \@@_backend_getbb_jpeg:n ,
+%     \@@_backend_getbb_pdf:n  ,
+%     \@@_backend_getbb_png:n  ,
+%     \@@_backend_getbb_bmp:n
 %   }
 % \begin{macro}{\@@_backend_getbb_auxi:nN}
 % \begin{macro}{\@@_backend_getbb_auxii:nnN, \@@_backend_getbb_auxii:VnN}
@@ -460,7 +529,9 @@
     \tl_clear:N \l_@@_pagebox_str
     \@@_backend_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D
   }
+\cs_new_eq:NN \@@_backend_getbb_jpeg:n \@@_backend_getbb_jpg:n
 \cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n
+\cs_new_eq:NN \@@_backend_getbb_bmp:n \@@_backend_getbb_jpg:n
 \cs_new_protected:Npn \@@_backend_getbb_pdf:n #1
   {
     \tl_clear:N \l_@@_decodearray_str
@@ -545,14 +616,26 @@
 %<*dvisvgm>
 %    \end{macrocode}
 %
+% \begin{variable}{\l_graphics_search_ext_seq}
+%    \begin{macrocode}
+\@@_backend_loaded:n
+  {
+    \seq_set_from_clist:Nn
+      \l_graphics_search_ext_seq
+      { .pdf , .eps , .png , .jpg , .jpeg }
+  }
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}{\@@_backend_getbb_eps:n}
 %   Simply use the generic function.
 %    \begin{macrocode}
-\cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n
+\@@_backend_loaded:n
+  { \cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb:n }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_backend_getbb_png:n, \@@_backend_getbb_jpg:n}
+% \begin{macro}{\@@_backend_getbb_png:n, \@@_backend_getbb_jpg:n, \@@_backend_getbb_jpeg:n}
 %   These can be included by extracting the bounding box data.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_getbb_jpg:n #1
@@ -561,6 +644,7 @@
     \tl_clear:N \l_@@_pagebox_str
     \@@_extract_bb:n {#1}
   }
+\cs_new_eq:NN \@@_backend_getbb_jpeg:n \@@_backend_getbb_jpg:n
 \cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n
 %    \end{macrocode}
 % \end{macro}
@@ -601,7 +685,12 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\@@_backend_include_png:n, \@@_backend_include_jpg:n}
+% \begin{macro}
+%   {
+%     \@@_backend_include_png:n ,
+%     \@@_backend_include_jpg:n ,
+%     \@@_backend_include_jpeg:n
+%   }
 % \begin{macro}{\@@_backend_include_bitmap_quote:w}
 %   The backend here has built-in support for basic graphic inclusion (see
 %   \texttt{dvisvgm.def} for a more complex approach, needed if clipping,
@@ -620,6 +709,7 @@
          \@@_backend_include_bitmap_quote:w #1 " #1 " \s_@@_stop
        }
   }
+\cs_new_eq:NN \@@_backend_include_jpeg:n \@@_backend_include_png:n
 \cs_new_eq:NN \@@_backend_include_jpg:n \@@_backend_include_png:n
 \cs_new:Npn \@@_backend_include_bitmap_quote:w #1 " #2 " #3 \s_@@_stop
   { " #2 " }
diff --git a/l3experimental/l3graphics/l3graphics.dtx b/l3experimental/l3graphics/l3graphics.dtx
index fc0cf6f18..b116e5216 100644
--- a/l3experimental/l3graphics/l3graphics.dtx
+++ b/l3experimental/l3graphics/l3graphics.dtx
@@ -458,7 +458,7 @@
 % \end{variable}
 %
 % \begin{variable}{\l_graphics_search_ext_seq}
-%   Used to specify fall-back extensions: actually set on a per-driver basis.
+%   Used to specify fall-back extensions: actually set on a per-backend basis.
 %    \begin{macrocode}
 \seq_new:N \l_graphics_search_ext_seq
 %    \end{macrocode}
@@ -512,7 +512,7 @@
   {
     \seq_map_inline:Nn \l_graphics_search_ext_seq
       {
-        \file_get_full_name:nNT { #1 . ##1 } \l_@@_full_name_str
+        \file_get_full_name:nNT { #1 ##1 } \l_@@_full_name_str
           { \seq_map_break:n { \use_i:nnn \@@_include: } }
       }
     \use:n





More information about the latex3-commits mailing list.