summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty293
1 files changed, 186 insertions, 107 deletions
diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty b/Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty
index a052de7518d..3b4f473f480 100644
--- a/Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty
+++ b/Master/texmf-dist/tex/latex/l3experimental/l3graphics/l3graphics.sty
@@ -20,54 +20,71 @@
%%
%% File: l3graphics.dtx
\RequirePackage{expl3}
-\ProvidesExplPackage{l3graphics}{2022-02-05}{}
+\ProvidesExplPackage{l3graphics}{2022-04-10}{}
{L3 Experimental graphics inclusion support}
-\ior_new:N \l__graphics_tmp_ior
-\tl_new:N \l__graphics_tmp_tl
+\ior_new:N \l__graphics_internal_ior
+\tl_new:N \l__graphics_internal_tl
\scan_new:N \s__graphics_stop
-\tl_new:N \l_graphics_decodearray_tl
-\tl_new:N \l_graphics_pagebox_tl
-\bool_new:N \l_graphics_interpolate_bool
-\tl_set:Nn \l_graphics_pagebox_tl { cropbox }
-\int_new:N \l_graphics_page_int
-\dim_new:N \l_graphics_llx_dim
-\dim_new:N \l_graphics_lly_dim
-\dim_new:N \l_graphics_urx_dim
-\dim_new:N \l_graphics_ury_dim
-\cs_new_protected:Npn \graphics_bb_save:n #1
+\tl_new:N \l__graphics_pagebox_tl
+\keys_define:nn { graphics }
+ {
+ decodearray .str_set:N =
+ \l__graphics_decodearray_str ,
+ draft .bool_set:N =
+ \l__graphics_draft_bool ,
+ interpolate .bool_set:N =
+ \l__graphics_interpolate_bool ,
+ pagebox .choices:nn =
+ { art , bleed , crop , media , trim }
+ {
+ \tl_set:Nx \l__graphics_pagebox_tl
+ { \tl_use:N \l_keys_choice_tl box }
+ } ,
+ pagebox .initial:n =
+ crop ,
+ page .int_set:N =
+ \l__graphics_page_int ,
+ type . str_set:N =
+ \l__graphics_type_str
+ }
+\dim_new:N \l__graphics_llx_dim
+\dim_new:N \l__graphics_lly_dim
+\dim_new:N \l__graphics_urx_dim
+\dim_new:N \l__graphics_ury_dim
+\cs_new_protected:Npn \__graphics_bb_save:n #1
{
\dim_if_exist:cTF { c__graphics_ #1 _urx_dim }
{ \msg_error:nnn { graphic } { bb-already-cached } {#1} }
{
- \dim_compare:nNnF \l_graphics_llx_dim = { 0pt }
- { \dim_const:cn { c__graphics_ #1 _llx_dim } { \l_graphics_llx_dim } }
- \dim_compare:nNnF \l_graphics_lly_dim = { 0pt }
- { \dim_const:cn { c__graphics_ #1 _lly_dim } { \l_graphics_lly_dim } }
- \dim_const:cn { c__graphics_ #1 _urx_dim } { \l_graphics_urx_dim }
- \dim_const:cn { c__graphics_ #1 _ury_dim } { \l_graphics_ury_dim }
+ \dim_compare:nNnF \l__graphics_llx_dim = { 0pt }
+ { \dim_const:cn { c__graphics_ #1 _llx_dim } { \l__graphics_llx_dim } }
+ \dim_compare:nNnF \l__graphics_lly_dim = { 0pt }
+ { \dim_const:cn { c__graphics_ #1 _lly_dim } { \l__graphics_lly_dim } }
+ \dim_const:cn { c__graphics_ #1 _urx_dim } { \l__graphics_urx_dim }
+ \dim_const:cn { c__graphics_ #1 _ury_dim } { \l__graphics_ury_dim }
}
}
-\cs_generate_variant:Nn \graphics_bb_save:n { x }
-\cs_new_protected:Npn \graphics_bb_restore:nF #1#2
+\cs_generate_variant:Nn \__graphics_bb_save:n { x }
+\cs_new_protected:Npn \__graphics_bb_restore:nF #1#2
{
\dim_if_exist:cTF { c__graphics_ #1 _urx_dim }
{
- \dim_set_eq:Nc \l_graphics_urx_dim { c__graphics_ #1 _urx_dim }
- \dim_set_eq:Nc \l_graphics_ury_dim { c__graphics_ #1 _ury_dim }
+ \dim_set_eq:Nc \l__graphics_urx_dim { c__graphics_ #1 _urx_dim }
+ \dim_set_eq:Nc \l__graphics_ury_dim { c__graphics_ #1 _ury_dim }
\dim_if_exist:cTF { c__graphics_ #1 _llx_dim }
- { \dim_set_eq:Nc \l_graphics_llx_dim { c__graphics_ #1 _llx_dim } }
- { \dim_zero:N \l_graphics_llx_dim }
+ { \dim_set_eq:Nc \l__graphics_llx_dim { c__graphics_ #1 _llx_dim } }
+ { \dim_zero:N \l__graphics_llx_dim }
\dim_if_exist:cTF { c__graphics_ #1 _lly_dim }
- { \dim_set_eq:Nc \l_graphics_lly_dim { c__graphics_ #1 _lly_dim } }
- { \dim_zero:N \l_graphics_lly_dim }
+ { \dim_set_eq:Nc \l__graphics_lly_dim { c__graphics_ #1 _lly_dim } }
+ { \dim_zero:N \l__graphics_lly_dim }
}
{#2}
}
-\cs_generate_variant:Nn \graphics_bb_restore:nF { x }
-\cs_new_protected:Npn \graphics_extract_bb:n #1
+\cs_generate_variant:Nn \__graphics_bb_restore:nF { x }
+\cs_new_protected:Npn \__graphics_extract_bb:n #1
{
- \int_compare:nNnTF \l_graphics_page_int > 0
- { \__graphics_extract_bb_auxi:Vn \l_graphics_page_int {#1} }
+ \int_compare:nNnTF \l__graphics_page_int > 0
+ { \__graphics_extract_bb_auxi:Vn \l__graphics_page_int {#1} }
{ \__graphics_extract_bb_auxii:nnn {#1} { } { } }
}
\cs_new_protected:Npn \__graphics_extract_bb_auxi:nn #1#2
@@ -75,9 +92,9 @@
\cs_generate_variant:Nn \__graphics_extract_bb_auxi:nn { Vn }
\cs_new_protected:Npn \__graphics_extract_bb_auxii:nnn #1#2#3
{
- \tl_if_empty:NTF \l_graphics_pagebox_tl
+ \tl_if_empty:NTF \l__graphics_pagebox_tl
{ \__graphics_extract_bb_auxiv:nnn }
- { \__graphics_extract_bb_auxiii:Vnnn \l_graphics_pagebox_tl }
+ { \__graphics_extract_bb_auxiii:Vnnn \l__graphics_pagebox_tl }
{#1} {#2} {#3}
}
\cs_new_protected:Npn \__graphics_extract_bb_auxiii:nnnn #1#2#3#4
@@ -86,42 +103,34 @@
\cs_new_protected:Npn \__graphics_extract_bb_auxiv:nnn #1#2#3
{
\__graphics_read_bb_auxi:nnnn {#1} {#2}
- { \ior_shell_open:Nn \l__graphics_tmp_ior { extractbb~#3-O~#1 } }
+ { \ior_shell_open:Nn \l__graphics_internal_ior { extractbb~#3-O~#1 } }
{ pipe-failed }
}
-\cs_new_protected:Npn \graphics_read_bb:n #1
+\cs_new_protected:Npn \__graphics_read_bb:n #1
{
\__graphics_read_bb_auxi:nnnn {#1} { }
- { \ior_open:Nn \l__graphics_tmp_ior {#1} }
+ { \ior_open:Nn \l__graphics_internal_ior {#1} }
{ graphic-not-found }
}
\cs_new_protected:Npn \__graphics_read_bb_auxi:nnnn #1#2#3#4
{
- \graphics_bb_restore:nF {#1#2}
+ \__graphics_bb_restore:nF {#1#2}
{ \__graphics_read_bb_auxii:nnnn {#3} {#4} {#1} {#2} }
}
\cs_new_protected:Npx \__graphics_read_bb_auxii:nnnn #1#2#3#4
{
#1
- \exp_not:N \ior_if_eof:NTF \exp_not:N \l__graphics_tmp_ior
+ \exp_not:N \ior_if_eof:NTF \exp_not:N \l__graphics_internal_ior
{ \msg_error:nnn { graphics } {#2} {#3} }
{
- \ior_str_map_inline:Nn \exp_not:N \l__graphics_tmp_ior
+ \ior_str_map_inline:Nn \exp_not:N \l__graphics_internal_ior
{
\exp_not:N \__graphics_read_bb_auxiii:w
##1 ~ \c_colon_str \s__graphics_stop
}
+ \__graphics_bb_save:n {#3#4}
}
- \exp_not:n
- {
- \ior_close:N \l__graphics_tmp_ior
- \dim_compare:nNnF \l_graphics_llx_dim = { 0pt }
- { \dim_const:cn { c__graphics_ #3#4 _llx_dim } { \l_graphics_llx_dim } }
- \dim_compare:nNnF \l_graphics_lly_dim = { 0pt }
- { \dim_const:cn { c__graphics_ #3#4 _lly_dim } { \l_graphics_lly_dim } }
- \dim_const:cn { c__graphics_ #3#4 _urx_dim } { \l_graphics_urx_dim }
- \dim_const:cn { c__graphics_ #3#4 _ury_dim } { \l_graphics_ury_dim }
- }
+ \ior_close:N \exp_not:N \l__graphics_internal_ior
}
\use:x
{
@@ -138,26 +147,25 @@
{
\str_if_eq:nnF {#2} { atend }
{
- \tl_set_rescan:Nnx \l__graphics_tmp_tl
+ \tl_set_rescan:Nnx \l__graphics_internal_tl
{
\char_set_catcode_space:n { 9 }
\char_set_catcode_space:n { 32 }
}
{ \use:n #1 }
- \exp_after:wN \__graphics_read_bb_auxv:w \l__graphics_tmp_tl \s__graphics_stop
+ \exp_after:wN \__graphics_read_bb_auxv:w \l__graphics_internal_tl \s__graphics_stop
}
}
\cs_new_protected:Npn \__graphics_read_bb_auxv:w #1~#2~#3~#4~#5 \s__graphics_stop
{
- \dim_set:Nn \l_graphics_llx_dim { #1 bp }
- \dim_set:Nn \l_graphics_lly_dim { #2 bp }
- \dim_set:Nn \l_graphics_urx_dim { #3 bp }
- \dim_set:Nn \l_graphics_ury_dim { #4 bp }
+ \dim_set:Nn \l__graphics_llx_dim { #1 bp }
+ \dim_set:Nn \l__graphics_lly_dim { #2 bp }
+ \dim_set:Nn \l__graphics_urx_dim { #3 bp }
+ \dim_set:Nn \l__graphics_ury_dim { #4 bp }
\ior_map_break:
}
-\bool_new:N \l_graphics_draft_bool
-\tl_new:N \l_graphics_name_tl
-\tl_new:N \l__graphics_name_tl
+\str_new:N \l__graphics_final_name_str
+\str_new:N \l__graphics_full_name_str
\box_new:N \l__graphics_internal_box
\str_new:N \l__graphics_dir_str
\str_new:N \l__graphics_name_str
@@ -167,50 +175,34 @@
\prop_new:N \l_graphics_ext_type_prop
\prop_put:Nnn \l_graphics_ext_type_prop { .ps } { eps }
\seq_new:N \g__graphics_record_seq
-\cs_new_protected:Npn \graphics_include:n #1
+\cs_new_protected:Npn \graphics_include:nn #1#2
{
\group_begin:
+ \keys_set:nn { graphics } {#1}
\seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
- \file_get_full_name:nNTF {#1} \l__graphics_name_tl
+ \file_get_full_name:nNTF {#2} \l__graphics_full_name_str
{
- \str_if_eq:eeTF { \l__graphics_name_tl } { #1 .tex }
- { \__graphics_include_search:n {#1} }
+ \str_if_eq:eeTF { \l__graphics_full_name_str } { #2 .tex }
+ { \msg_error:nnn { graphics } { graphic-not-found } {#2} }
{ \__graphics_include: }
}
- { \__graphics_include_search:n {#1} }
+ { \msg_error:nnn { graphics } { graphic-not-found } {#2} }
\group_end:
}
-\cs_new_protected:Npn \__graphics_include_search:n #1
- {
- \seq_map_inline:Nn \l_graphics_search_ext_seq
- {
- \file_get_full_name:nNT { #1 . ##1 } \l__graphics_name_tl
- { \seq_map_break:n { \use_i:nnn \__graphics_include: } }
- }
- \use:n
- { \msg_error:nnn { graphics } { graphic-not-found } {#1} }
- }
+\cs_generate_variant:Nn \graphics_include:nn { nV }
\cs_new_protected:Npn \__graphics_include:
{
- \file_parse_full_name:VNNN \l__graphics_name_tl
- \l__graphics_dir_str \l__graphics_name_str \l__graphics_ext_str
- \exp_args:Ne \__graphics_include_auxi:n
+ \str_if_empty:NTF \l__graphics_type_str
{
- \exp_args:Ne \str_tail:n
- { \str_foldcase:V \l__graphics_ext_str }
- }
- }
-\cs_new_protected:Npn \graphics_include:nn #1#2
- {
- \group_begin:
- \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
- \file_get_full_name:nNTF {#1} \l__graphics_name_tl
- {
- \exp_args:Ne \__graphics_include_auxi:n
- { \str_foldcase:n {#1} }
- }
- { \msg_error:nnn { graphics } { graphic-not-found } {#1} }
- \group_end:
+ \file_parse_full_name:VNNN \l__graphics_full_name_str
+ \l__graphics_dir_str \l__graphics_name_str \l__graphics_ext_str
+ \__graphics_include_auxi:e
+ {
+ \exp_args:Ne \str_tail:n
+ { \str_foldcase:V \l__graphics_ext_str }
+ }
+ }
+ { \__graphics_include_auxi:e { \l__graphics_type_str } }
}
\cs_new_protected:Npn \__graphics_include_auxi:n #1
{
@@ -218,18 +210,21 @@
{ \tl_set:Nn \l__graphics_internal_tl {#1} }
\exp_args:NV \__graphics_include_auxii:n \l__graphics_internal_tl
}
+\cs_generate_variant:Nn \__graphics_include_auxi:n { e }
\cs_new_protected:Npn \__graphics_include_auxii:n #1
{
\mode_leave_vertical:
\cs_if_exist:cTF { __graphics_backend_include_ #1 :n }
{
- \tl_set_eq:NN \l_graphics_name_tl \l__graphics_name_tl
+ \tl_set_eq:NN \l__graphics_final_name_str \l__graphics_full_name_str
+ \str_set:Nx \l__graphics_full_name_str
+ { \exp_args:NV \__kernel_file_name_quote:n \l__graphics_full_name_str }
\exp_args:NnV \use:c { __graphics_backend_getbb_ #1 :n }
- \l__graphics_name_tl
- \seq_gput_right:NV \g__graphics_record_seq \l_graphics_name_tl
+ \l__graphics_full_name_str
+ \seq_gput_right:NV \g__graphics_record_seq \l__graphics_final_name_str
\clist_if_exist:NT \@filelist
- { \exp_args:NV \@addtofilelist \l_graphics_name_tl }
- \bool_if:NTF \l_graphics_draft_bool
+ { \exp_args:NV \@addtofilelist \l__graphics_final_name_str }
+ \bool_if:NTF \l__graphics_draft_bool
{ \__graphics_include_auxiii:n }
{ \__graphics_include_auxiv:n }
{#1}
@@ -238,21 +233,21 @@
}
\cs_new_protected:Npn \__graphics_include_auxiii:n #1
{
- \hbox_to_wd:nn { \l_graphics_urx_dim - \l_graphics_llx_dim }
+ \hbox_to_wd:nn { \l__graphics_urx_dim - \l__graphics_llx_dim }
{
\tex_vrule:D
\tex_hss:D
\vbox_to_ht:nn
- { \l_graphics_ury_dim - \l_graphics_lly_dim }
+ { \l__graphics_ury_dim - \l__graphics_lly_dim }
{
\tex_hrule:D width
- \dim_eval:n { \l_graphics_urx_dim - \l_graphics_llx_dim }
+ \dim_eval:n { \l__graphics_urx_dim - \l__graphics_llx_dim }
\tex_vss:D
\hbox_to_wd:nn
- { \l_graphics_urx_dim - \l_graphics_llx_dim }
+ { \l__graphics_urx_dim - \l__graphics_llx_dim }
{
\ttfamily
- \tex_hss:D \l__graphics_name_tl \tex_hss:D
+ \tex_hss:D \l__graphics_full_name_str \tex_hss:D
}
\tex_vss:D
\tex_hrule:D
@@ -266,13 +261,13 @@
\hbox_set:Nn \l__graphics_internal_box
{
\exp_args:NnV \use:c { __graphics_backend_include_ #1 :n }
- \l__graphics_name_tl
+ \l__graphics_full_name_str
}
\box_set_dp:Nn \l__graphics_internal_box { 0pt }
\box_set_ht:Nn \l__graphics_internal_box
- { \l_graphics_ury_dim - \l_graphics_lly_dim }
+ { \l__graphics_ury_dim - \l__graphics_lly_dim }
\box_set_wd:Nn \l__graphics_internal_box
- { \l_graphics_urx_dim - \l_graphics_llx_dim }
+ { \l__graphics_urx_dim - \l__graphics_llx_dim }
\box_use_drop:N \l__graphics_internal_box
}
\cs_new_protected:Npn \graphics_show_list: { \__graphics_list:N \msg_show:nnxxxx }
@@ -280,16 +275,100 @@
\cs_new_protected:Npn \__graphics_list:N #1
{
\seq_remove_duplicates:N \g__graphics_record_seq
- #1 { LaTeX/kernel } { file-list }
+ #1 { kernel } { file-list }
{ \seq_map_function:NN \g__graphics_record_seq \__graphics_list_aux:n }
{ } { } { }
}
\cs_new:Npn \__graphics_list_aux:n #1 { \iow_newline: #1 }
+\cs_new_protected:Npn \graphics_get_full_name:nN #1#2
+ {
+ \graphics_get_full_name:nNF {#1} #2
+ { \tl_set:Nn #2 { \q_no_value } }
+ }
+\prg_new_protected_conditional:Npnn \graphics_get_full_name:nN #1#2
+ { T , F , TF }
+ {
+ \group_begin:
+ \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
+ \file_get_full_name:nNTF {#1} \l__graphics_full_name_str
+ {
+ \str_if_eq:eeT { \l__graphics_full_name_str } { #1 .tex }
+ { \__graphics_get_full_name:n {#1} }
+ }
+ { \__graphics_get_full_name:n {#1} }
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn #2 \l__graphics_full_name_str
+ \tl_if_empty:NTF #2
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\cs_new_protected:Npn \__graphics_get_full_name:n #1
+ {
+ \str_clear:N \l__graphics_full_name_str
+ \seq_map_inline:Nn \l_graphics_search_ext_seq
+ {
+ \file_get_full_name:nNT { #1 ##1 } \l__graphics_full_name_str
+ { \seq_map_break:n { \use_none:nn } }
+ }
+ \use:n
+ { \str_clear:N \l__graphics_full_name_str }
+ }
+\cs_new_protected:Npn \graphics_get_pagecount:nN #1#2
+ {
+ \group_begin:
+ \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
+ \file_get_full_name:nNTF {#1} \l__graphics_full_name_str
+ {
+ \int_if_exist:cF { c__graphics_ \l__graphics_full_name_str _pages_int }
+ {
+ \exp_args:NV \__graphics_backend_get_pagecount:n
+ \l__graphics_full_name_str
+ }
+ \tl_set:Nv #2 { c__graphics_ \l__graphics_full_name_str _pages_int }
+ }
+ {
+ \tl_set:Nn #2 { 0 }
+ \msg_error:nnn { graphics } { graphic-not-found } {#1}
+ }
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn #2 #2
+ }
+\cs_new_protected:Npx \__graphics_get_pagecount:n #1
+ {
+ \ior_shell_open:Nn \exp_not:N \l__graphics_internal_ior
+ { extractbb~-O~#1 }
+ \exp_not:N \ior_if_eof:NTF \exp_not:N \l__graphics_internal_ior
+ { \msg_error:nnn { graphics } { pipe-failed } }
+ {
+ \ior_str_map_inline:Nn \exp_not:N \l__graphics_internal_ior
+ {
+ \exp_not:N \__graphics_get_pagecount:nw {#1}
+ ##1 ~ \c_colon_str \c_colon_str \s__graphics_stop
+ }
+ \exp_not:N \int_if_exist:cF { c__graphics_ #1 _pages_int }
+ { \int_const:cn { c__graphics_ #1 _pages_int } { 1 } }
+ }
+ \ior_close:N \exp_not:N \l__graphics_internal_ior
+ }
+\use:x
+ {
+ \cs_new_protected:Npn \exp_not:N \__graphics_get_pagecount:nw
+ ##1##2 \c_colon_str ##3 \c_colon_str ##4 \s__graphics_stop
+ {
+ \exp_not:N \str_if_eq:nnT
+ { \c_percent_str \c_percent_str Pages }
+ {##2}
+ {
+ \int_const:cn { c__graphics_ ##1 _pages_int } {##3}
+ \exp_not:N \ior_map_break:
+ }
+ }
+ }
\msg_new:nnnn { graphics } { graphic-not-found }
{ Image~file~'#1'~not~found. }
{
- LaTeX~tried~to~open~graphic~file~'#1',
- ~but~the~file~could~not~be~read.
+ LaTeX~tried~to~open~graphic~file~'#1',~
+ but~the~file~could~not~be~read.
}
\msg_new:nnnn { graphics } { pipe-failed }
{ Cannot~run~piped~system~commands. }