[latex3-commits] [git/LaTeX3-latex3-latex3] master: Support \DeclareGraphicsExtention-like ext-type mapping (f07e867)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun May 12 20:52:35 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/f07e867918a848f6175ba664f9fbd20761a36ae9
>---------------------------------------------------------------
commit f07e867918a848f6175ba664f9fbd20761a36ae9
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Sun May 12 19:52:35 2019 +0100
Support \DeclareGraphicsExtention-like ext-type mapping
>---------------------------------------------------------------
f07e867918a848f6175ba664f9fbd20761a36ae9
l3experimental/l3graphics/l3graphics.dtx | 47 +++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 7 deletions(-)
diff --git a/l3experimental/l3graphics/l3graphics.dtx b/l3experimental/l3graphics/l3graphics.dtx
index f9b2847..09bc1b3 100644
--- a/l3experimental/l3graphics/l3graphics.dtx
+++ b/l3experimental/l3graphics/l3graphics.dtx
@@ -185,6 +185,16 @@
% stored in \cs{l_graphics_search_ext_seq}.
% \end{function}
%
+% \begin{variable}{\l_graphics_ext_type_prop}
+% Defines mapping between file extensions and file types; where there is
+% no entry for an extension, the type is assumed to be the extension
+% with the leading |.| removed. Entries should be made in lower case, and
+% the key should be an extension including the leading |.|, for example
+% \begin{verbatim}
+% \prop_put:Nnn \l_graphics_ext_type_prop { .ps } { eps }
+% \end{verbatim}
+% \end{variable}
+%
% \begin{variable}{\l_graphics_search_ext_seq}
% Extensions to use for image searching when the given \meta{file} name is not
% found by \cs{image_include:n}.
@@ -500,6 +510,14 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}{\l_graphics_ext_type_prop}
+% Mapping between extensions and types for non-standard mappings
+% \begin{macrocode}
+\prop_new:N \l_graphics_ext_type_prop
+\prop_put:Nnn \l_graphics_ext_type_prop { .ps } { eps }
+% \end{macrocode}
+% \end{variable}
+%
% \begin{variable}{\g_@@_record_seq}
% A list of image files used.
% \begin{macrocode}
@@ -512,7 +530,10 @@
% \begin{macro}{\@@_include:}
% \begin{macro}{\graphics_include:nn}
% \begin{macro}
-% {\@@_include:n, \@@_include_auxi:n, \@@_include_auxii:n, \@@_include_auxiii:n}
+% {
+% \@@_include_auxi:n, \@@_include_auxii:n,
+% \@@_include_auxiii:n, \@@_include_auxiv: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. Where the first given name is not found, we
@@ -547,6 +568,11 @@
{
\file_parse_full_name:VNNN \l_@@_name_tl
\l_@@_dir_str \l_@@_name_str \l_@@_ext_str
+ \exp_args:Ne \@@_include_auxi:n
+ {
+ \exp_args:Ne \str_tail:n
+ { \str_fold_case:V \l_@@_ext_str }
+ }
\exp_args:Nx \@@_include:n
{ \str_tail:N \l_@@_ext_str }
}
@@ -555,14 +581,21 @@
\group_begin:
\seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
\file_get_full_name:nNTF {#1} \l_@@_name_tl
- { \@@_include:n {#2} }
+ {
+ \exp_args:Ne \@@_include_auxi:n
+ { \str_fold_case:n {#1} }
+ }
{ \__kernel_msg_error:nnn { image } { image-not-found } {#1} }
\group_end:
}
-\cs_new_protected:Npn \@@_include:n #1
- { \exp_args:Ne \@@_include_auxi:n { \str_fold_case:n {#1} } }
\cs_new_protected:Npn \@@_include_auxi:n #1
{
+ \prop_get:NnNF \l_graphics_ext_type_prop { .#1 } \l_@@_internal_tl
+ { \tl_set:Nn \l_@@_internal_tl {#1} }
+ \exp_args:NV \@@_include_auxii:n \l_@@_internal_tl
+ }
+\cs_new_protected:Npn \@@_include_auxii:n #1
+ {
\mode_leave_vertical:
\cs_if_exist:cTF { driver_graphics_include_ #1 :n }
{
@@ -574,13 +607,13 @@
{ \exp_args:NV \@addtofilelist \l_@@_name_tl }
%</package>
\bool_if:NTF \l_graphics_draft_bool
- { \@@_include_auxii:n }
{ \@@_include_auxiii:n }
+ { \@@_include_auxiv:n }
{#1}
}
{ \__kernel_msg_error:nnn { image } { unsupported-image-type } {#1} }
}
-\cs_new_protected:Npn \@@_include_auxii:n #1
+\cs_new_protected:Npn \@@_include_auxiii:n #1
{
\hbox_to_wd:nn { \l_graphics_urx_dim - \l_graphics_llx_dim }
{
@@ -607,7 +640,7 @@
\tex_vrule:D
}
}
-\cs_new_protected:Npn \@@_include_auxiii:n #1
+\cs_new_protected:Npn \@@_include_auxiv:n #1
{
\hbox_set:Nn \l_@@_internal_box
{
More information about the latex3-commits
mailing list