summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3backend/l3backend-graphics.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-04-15 03:00:41 +0000
committerNorbert Preining <norbert@preining.info>2022-04-15 03:00:41 +0000
commitd82d72343a5dfcbc4ba14569fba7f9e34debdf71 (patch)
treee352abde532b9c5839b13499878d2b726f8d7e02 /macros/latex/contrib/l3backend/l3backend-graphics.dtx
parentef28ae824b7f6bc8e2b9c08443b53fd2ef37a781 (diff)
CTAN sync 202204150300
Diffstat (limited to 'macros/latex/contrib/l3backend/l3backend-graphics.dtx')
-rw-r--r--macros/latex/contrib/l3backend/l3backend-graphics.dtx184
1 files changed, 155 insertions, 29 deletions
diff --git a/macros/latex/contrib/l3backend/l3backend-graphics.dtx b/macros/latex/contrib/l3backend/l3backend-graphics.dtx
index 1bd6a7e336..08df3f16b5 100644
--- a/macros/latex/contrib/l3backend/l3backend-graphics.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-graphics.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2022-04-10}
+% \date{Released 2022-04-14}
%
% \maketitle
%
@@ -143,7 +143,7 @@
{
\seq_set_from_clist:Nn
\l_graphics_search_ext_seq
- { .pdf , .eps , .png , .jpg , .jpeg }
+ { .pdf , .eps , .ps , .png , .jpg , .jpeg }
}
% \end{macrocode}
% \end{variable}
@@ -282,9 +282,9 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_backend_getbb_eps:n}
+% \begin{macro}{\@@_backend_getbb_eps:n, \@@_backend_getbb_ps:n}
% \begin{macro}{\@@_backend_getbb_eps:nm}
-% \begin{macro}{\@@_backend_include_eps:n}
+% \begin{macro}{\@@_backend_include_eps:n, \@@_backend_include_ps:n}
% \begin{variable}
% {\l_@@_backend_dir_str, \l_@@_backend_name_str, \l_@@_backend_ext_str}
% EPS graphics may be included in \LuaTeX{}/pdfTeX{} by conversion to
@@ -314,6 +314,7 @@
}
{#1}
}
+ \cs_new_eq:NN \@@_backend_getbb_ps:n \@@_backend_getbb_eps:n
\cs_new_protected:Npn \@@_backend_getbb_eps:nn #1#2
{
\file_compare_timestamp:nNnT {#2} > {#1}
@@ -338,6 +339,7 @@
}
}
}
+ \cs_new_eq:NN \@@_backend_include_ps:n \@@_backend_include_eps:n
}
% \end{macrocode}
% \end{variable}
@@ -379,7 +381,7 @@
%
% \begin{macro}
% {
-% \@@_backend_getbb_eps:n ,
+% \@@_backend_getbb_eps:n , \@@_backend_getbb_ps:n ,
% \@@_backend_getbb_jpg:n , \@@_backend_getbb_jpeg:n ,
% \@@_backend_getbb_pdf:n , \@@_backend_getbb_png:n ,
% \@@_backend_getbb_bmp:n
@@ -640,7 +642,7 @@
% For PDF graphics, properly supporting the |pagebox| concept in \XeTeX{}
% is best done using the |\tex_XeTeXpdffile:D| primitive. The syntax here
% is the same as for the graphic measurement part, although we know at this
-% stage that there must be some valid setting for \cs{l_graphics_pagebox_tl}.
+% stage that there must be some valid setting for \cs{l_@@_pagebox_tl}.
% \begin{macrocode}
\cs_new_protected:Npn \@@_backend_include_pdf:n #1
{
@@ -683,16 +685,123 @@
{
\seq_set_from_clist:Nn
\l_graphics_search_ext_seq
- { .pdf , .eps , .png , .jpg , .jpeg }
+ { .svg , .pdf , .eps , .ps , .png , .jpg , .jpeg }
}
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}{\@@_backend_getbb_eps:n}
+% \begin{macro}{\@@_backend_getbb_svg:n}
+% \begin{macro}{\@@_backend_getbb_svg_auxi:nNn}
+% \begin{macro}{\@@_backend_getbb_svg_auxii:w}
+% \begin{macro}
+% {
+% \@@_backend_getbb_svg_auxiii:Nw ,
+% \@@_backend_getbb_svg_auxiv:Nw ,
+% \@@_backend_getbb_svg_auxv:Nw
+% }
+% \begin{macro}{\@@_backend_getbb_svg_auxvi:Nn}
+% \begin{macro}{\@@_backend_getbb_svg_auxvii:w}
+% This is relatively similar to reading bounding boxes for |.eps| files. Life
+% is though made more tricky as we cannot pick a single line for the data. So
+% we have to loop until we collect up both height and width. To do that, we
+% can use a marker value. We also have to allow for the default units of the
+% lengths: they are big points and may be omitted.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_getbb_svg:n #1
+ {
+ \@@_bb_restore:nF {#1}
+ {
+ \ior_open:Nn \l_@@_internal_ior {#1}
+ \ior_if_eof:NTF \l_@@_internal_ior
+ { \msg_error:nnn { graphics } { graphic-not-found } {#1} }
+ {
+ \dim_zero:N \l_@@_llx_dim
+ \dim_zero:N \l_@@_lly_dim
+ \dim_set:Nn \l_@@_urx_dim { -\c_max_dim }
+ \dim_set:Nn \l_@@_ury_dim { -\c_max_dim }
+ \ior_str_map_inline:Nn \l_@@_internal_ior
+ {
+ \dim_compare:nNnT \l_@@_urx_dim = { -\c_max_dim }
+ {
+ \@@_backend_getbb_svg_auxi:nNn
+ { width } \l_@@_urx_dim {##1}
+ }
+ \dim_compare:nNnT \l_@@_ury_dim = { -\c_max_dim }
+ {
+ \@@_backend_getbb_svg_auxi:nNn
+ { height } \l_@@_ury_dim {##1}
+ }
+ \bool_lazy_and:nnF
+ { \dim_compare_p:nNn \l_@@_urx_dim = { -\c_max_dim } }
+ { \dim_compare_p:nNn \l_@@_ury_dim = { -\c_max_dim } }
+ { \ior_map_break: }
+ }
+ \@@_bb_save:n {#1}
+ }
+ \ior_close:N \l_@@_internal_ior
+ }
+ }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxi:nNn #1#2#3
+ {
+ \use:x
+ {
+ \cs_set_protected:Npn \@@_backend_getbb_svg_auxii:w
+ ####1 \tl_to_str:n {#1} = ####2 \tl_to_str:n {#1} = ####3
+ \s_@@_stop
+ }
+ {
+ \tl_if_blank:nF {##2}
+ {
+ \peek_remove_spaces:n
+ {
+ \peek_meaning:NTF ' % '
+ { \@@_backend_getbb_svg_auxiii:Nw #2 }
+ {
+ \peek_meaning:NTF " % "
+ { \@@_backend_getbb_svg_auxiv:Nw #2 }
+ { \@@_backend_getbb_svg_auxv:Nw #2 }
+ }
+ }
+ ##2 \s_@@_stop
+ }
+ }
+ \use:x
+ {
+ \@@_backend_getbb_svg_auxii:w #3
+ \tl_to_str:n {#1} = \tl_to_str:n {#1} =
+ \s_@@_stop
+ }
+ }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxii:w { }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxiii:Nw #1 ' #2 ' #3 \s_@@_stop
+ { \@@_backend_getbb_svg_auxvi:Nn #1 {#2} }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxiv:Nw #1 " #2 " #3 \s_@@_stop
+ { \@@_backend_getbb_svg_auxvi:Nn #1 {#2} }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxv:Nw #1 #2 ~ #3 \s_@@_stop
+ { \@@_backend_getbb_svg_auxvi:Nn #1 {#2} }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxvi:Nn #1#2
+ {
+ \tex_afterassignment:D \@@_backend_getbb_svg_auxvii:w
+ \l_@@_internal_dim #2 bp \scan_stop:
+ \dim_set_eq:NN #1 \l_@@_internal_dim
+ }
+\cs_new_protected:Npn \@@_backend_getbb_svg_auxvii:w #1 \scan_stop: { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@_backend_getbb_eps:n, \@@_backend_getbb_ps:n}
% Simply use the generic function.
% \begin{macrocode}
\@@_backend_loaded:n
- { \cs_new_eq:NN \@@_backend_getbb_eps:n \@@_read_bb: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}
%
@@ -722,13 +831,19 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_backend_include_eps:n, \@@_backend_include_pdf:n}
+% \begin{macro}
+% {
+% \@@_backend_include_eps:n ,
+% \@@_backend_include_ps:n ,
+% \@@_backend_include_pdf:n
+% }
% \begin{macro}{\@@_backend_include:nn}
% The special syntax is relatively clear here: remember we need PostScript
% sizes here. (This is the same as the \texttt{dvips} code.)
% \begin{macrocode}
\cs_new_protected:Npn \@@_backend_include_eps:n #1
{ \@@_backend_include:nn { PSfile } {#1} }
+\cs_new_eq:NN \@@_backend_include_ps:n \@@_backend_include_eps:n
\cs_new_protected:Npn \@@_backend_include_pdf:n #1
{ \@@_backend_include:nn { pdffile } {#1} }
\cs_new_protected:Npn \@@_backend_include:nn #1#2
@@ -748,32 +863,43 @@
%
% \begin{macro}
% {
+% \@@_backend_include_svg:n ,
% \@@_backend_include_png:n ,
% \@@_backend_include_jpg:n ,
% \@@_backend_include_jpeg:n
% }
-% \begin{macro}{\@@_backend_include_bitmap_quote:w}
+% \begin{macro}{\@@_backend_include_dequote:w}
% The backend here has built-in support for basic graphic inclusion (see
% \texttt{dvisvgm.def} for a more complex approach, needed if clipping,
-% \emph{etc.}, is covered at the graphic backend level). The only issue is
-% that |#1| must be quote-corrected. The \texttt{dvisvgm:img} operation
-% quotes the file name, but if it is already quoted (contains spaces)
-% then we have an issue: we simply strip off any quotes as a result.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_include_png:n #1
- {
- \__kernel_backend_literal:x
- {
- dvisvgm:img~
- \dim_to_decimal:n { \l_@@_ury_dim } ~
- \dim_to_decimal:n { \l_@@_ury_dim } ~
- \@@_backend_include_bitmap_quote:w #1 " #1 " \s_@@_stop
- }
+% \emph{etc.}, is covered at the graphic backend level). We have to deal
+% with the fact that the image reference point is at the \emph{top}, so
+% there is a need for a veritcal shift to put it in the right place.
+% The other issue is that |#1| must be quote-corrected. The
+% \texttt{dvisvgm:img} operation quotes the file name, but if it is already
+% quoted (contains spaces) then we have an issue: we simply strip off any
+% quotes as a result.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_include_svg:n #1
+ {
+ \box_move_up:nn { \l_@@_ury_dim }
+ {
+ \hbox:n
+ {
+ \__kernel_backend_literal:x
+ {
+ dvisvgm:img~
+ \dim_to_decimal:n { \l_@@_urx_dim } ~
+ \dim_to_decimal:n { \l_@@_ury_dim } ~
+ \@@_backend_include_dequote: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 " }
+\cs_new_eq:NN \@@_backend_include_png:n \@@_backend_include_svg:n
+\cs_new_eq:NN \@@_backend_include_jpeg:n \@@_backend_include_svg:n
+\cs_new_eq:NN \@@_backend_include_jpg:n \@@_backend_include_svg:n
+\cs_new:Npn \@@_backend_include_dequote:w #1 " #2 " #3 \s_@@_stop
+ {#2}
% \end{macrocode}
% \end{macro}
% \end{macro}