[latex3-commits] [git/LaTeX3-latex3-latex3] master: First version of image inclusion code (e9830f8)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue May 7 22:54:19 CEST 2019


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

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

commit e9830f8f989352eea7796dcf6b8d8d7128112670
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue May 7 21:49:12 2019 +0100

    First version of image inclusion code


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

e9830f8f989352eea7796dcf6b8d8d7128112670
 l3trial/l3image/l3image.dtx |  102 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/l3trial/l3image/l3image.dtx b/l3trial/l3image/l3image.dtx
index 80fb462..3f0948d 100644
--- a/l3trial/l3image/l3image.dtx
+++ b/l3trial/l3image/l3image.dtx
@@ -162,6 +162,26 @@
 %   |.bb|/|.xbb| are appropriate for parsing using this function.
 % \end{function}
 %
+% \begin{function}{\image_include:n, \image_include:nn}
+%   \begin{syntax}
+%     \cs{image_include:n} \Arg{file}
+%     \cs{image_include:nn} \Arg{file} \Arg{type}
+%   \end{syntax}
+%   Horizontal-mode commands which include the \meta{file} as an image
+%   at the current location. The file \meta{type} is given explicitly in
+%   the two-argument version, or is inferred from the file extension extracted
+%   in the single-argument form. The exact image types supported depend upon
+%   the driver in use.
+% \end{function}
+%
+% \begin{variable}{\l_image_search_path_seq}
+%   Each entry is the path to a directory which should be searched when
+%   seeking an image file. Each path can be relative or absolute, and should
+%   not include the trailing slash. The entries are not expanded when
+%   used so may contain active characters but should not feature any
+%   variable content. Spaces need not be quoted.
+% \end{variable}
+%
 % \end{documentation}
 %
 % \begin{implementation}
@@ -412,6 +432,82 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{variable}{\l_@@_name_tl}
+%    \begin{macrocode}
+\tl_new:N \l_@@_name_tl
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_@@_internal_box}
+%    \begin{macrocode}
+\box_new:N \l_@@_internal_box
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_@@_dir_str \l_@@_name_str \l_@@_ext_str}
+%    \begin{macrocode}
+\str_new:N \l_@@_dir_str
+\str_new:N \l_@@_name_str
+\str_new:N \l_@@_ext_str
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_image_search_path_seq}
+%    \begin{macrocode}
+\seq_new:N \l_image_search_path_seq
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\image_include:n, \image_include:nn}
+% \begin{macro}{\@@_include:n}
+%   Actually including an image is relatively straight-forward: most of the
+%   work is done by the driver. We only have to deal with making sure the
+%   box has no apparent depth.
+%    \begin{macrocode}
+\cs_new_protected:Npn \image_include:n #1
+  {
+    \group_begin:
+      \seq_set_eq:NN \l_file_search_path_seq \l_image_search_path_seq
+      \file_get_full_name:nNTF {#1} \l_@@_name_tl
+        {
+          \file_parse_full_name:VNNN \l_@@_name_tl
+            \l_@@_dir_str \l_@@_name_str \l_@@_ext_str
+          \exp_args:Nx \@@_include:n
+            { \str_tail:N \l_@@_ext_str }
+        }
+        { \__kernel_msg_error:nnn { image } { image-not-found } {#1} }
+    \group_end:
+  }
+\cs_new_protected:Npn \image_include:nn #1#2
+  {
+    \group_begin:
+      \seq_set_eq:NN \l_file_search_path_seq \l_image_search_path_seq
+      \file_get_full_name:nNTF {#1} \l_@@_name_tl
+        { \@@_include:n {#2} }
+        { \__kernel_msg_error:nnn { image } { image-not-found } {#1} }
+    \group_end:
+  }
+\cs_new_protected:Npn \@@_include:n #1
+  {
+    \mode_leave_vertical:
+    \cs_if_exist:cTF { driver_image_include_ #1 :n }
+      {
+        \exp_args:NnV \use:c { driver_image_getbb_ #1 :n }
+          \l_@@_name_tl
+        \hbox_set:Nn \l_@@_internal_box
+          {
+            \exp_args:NnV \use:c { driver_image_include_ #1 :n }
+              \l_@@_name_tl
+          }
+        \box_set_dp:Nn \l_@@_internal_box { 0pt }
+        \box_use_drop:N \l_@@_internal_box
+      }
+      { \__kernel_msg_error:nnn { image } { unsupported-image-type } {#1} }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \subsection{Messages}
 %
 %    \begin{macrocode}
@@ -427,6 +523,12 @@
     LaTeX~tried~to~call~a~system~process~but~this~was~not~possible.\\
     Try~the~"--shell-escape"~(or~"--enable-pipes")~option.
   }
+\__kernel_msg_new:nnnn { image } { unsupported-image-type }
+  { Image~type~'#1'~not~supported~by~current~driver. }
+  {
+    LaTeX~was~asked~to~include~an~image~of~type~'#1',~
+    but~this~is~not~supported~by~the~current~driver~(production~route).
+  }
 %    \end{macrocode}
 %
 %    \begin{macrocode}





More information about the latex3-commits mailing list