You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

308 lines
11 KiB

%%
%% This is file `l3graphics.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3graphics.dtx (with options: `package')
%%
%% Copyright (C) 2019,2020 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version. The latest
%% version of this license is in the file:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3experimental bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% File: l3graphics.dtx
\RequirePackage{expl3}
\ProvidesExplPackage{l3graphics}{2020-08-07}{}
{L3 Experimental graphics inclusion support}
\ior_new:N \l__graphics_tmp_ior
\tl_new:N \l__graphics_tmp_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
{
\dim_if_exist:cTF { c__graphics_ #1 _urx_dim }
{ \__kernel_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 }
}
}
\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_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_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 }
}
{#2}
}
\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} }
{ \__graphics_extract_bb_auxii:nnn {#1} { } { } }
}
\cs_new_protected:Npn \__graphics_extract_bb_auxi:nn #1#2
{ \__graphics_extract_bb_auxii:nnn {#2} { :P #1 } { -p~#1~ } }
\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
{ \__graphics_extract_bb_auxiv:nnn }
{ \__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
{ \__graphics_extract_bb_auxiv:nnn {#2} { : #1 #3 } { #4 -B~#1~ } }
\cs_generate_variant:Nn \__graphics_extract_bb_auxiii:nnnn { V }
\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 } }
{ pipe-failed }
}
\cs_new_protected:Npn \graphics_read_bb:n #1
{
\__graphics_read_bb_auxi:nnnn {#1} { }
{ \ior_open:Nn \l__graphics_tmp_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_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
{ \__kernel_msg_error:nnn { graphics } {#2} {#3} }
{
\ior_str_map_inline:Nn \exp_not:N \l__graphics_tmp_ior
{
\exp_not:N \__graphics_read_bb_auxiii:w
##1 ~ \c_colon_str \s__graphics_stop
}
}
\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 }
}
}
\use:x
{
\cs_new_protected:Npn \exp_not:N \__graphics_read_bb_auxiii:w
##1 \c_colon_str ##2 \s__graphics_stop
{
\exp_not:N \str_if_eq:nnT
{ \c_percent_str \c_percent_str BoundingBox }
{##1}
{ \exp_not:N \__graphics_read_bb_auxiv:w ##2 ( ) \s__graphics_stop }
}
}
\cs_new_protected:Npn \__graphics_read_bb_auxiv:w #1 ( #2 ) #3 \s__graphics_stop
{
\str_if_eq:nnF {#2} { atend }
{
\tl_set_rescan:Nnx \l__graphics_tmp_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
}
}
\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 }
\ior_map_break:
}
\bool_new:N \l_graphics_draft_bool
\tl_new:N \l_graphics_name_tl
\tl_new:N \l__graphics_name_tl
\box_new:N \l__graphics_internal_box
\str_new:N \l__graphics_dir_str
\str_new:N \l__graphics_name_str
\str_new:N \l__graphics_ext_str
\seq_new:N \l_graphics_search_path_seq
\seq_new:N \l_graphics_search_ext_seq
\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
{
\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
{
\str_if_eq:eeTF { \l__graphics_name_tl } { #1 .tex }
{ \__graphics_include_search:n {#1} }
{ \__graphics_include: }
}
{ \__graphics_include_search:n {#1} }
\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
{ \__kernel_msg_error:nnn { graphics } { graphic-not-found } {#1} }
}
\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
{
\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} }
}
{ \__kernel_msg_error:nnn { graphics } { graphic-not-found } {#1} }
\group_end:
}
\cs_new_protected:Npn \__graphics_include_auxi:n #1
{
\prop_get:NnNF \l_graphics_ext_type_prop { .#1 } \l__graphics_internal_tl
{ \tl_set:Nn \l__graphics_internal_tl {#1} }
\exp_args:NV \__graphics_include_auxii:n \l__graphics_internal_tl
}
\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
\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
\clist_if_exist:NT \@filelist
{ \exp_args:NV \@addtofilelist \l_graphics_name_tl }
\bool_if:NTF \l_graphics_draft_bool
{ \__graphics_include_auxiii:n }
{ \__graphics_include_auxiv:n }
{#1}
}
{ \__kernel_msg_error:nnn { graphics } { unsupported-graphic-type } {#1} }
}
\cs_new_protected:Npn \__graphics_include_auxiii:n #1
{
\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 }
{
\tex_hrule:D width
\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 }
{
\ttfamily
\tex_hss:D \l__graphics_name_tl \tex_hss:D
}
\tex_vss:D
\tex_hrule:D
}
\tex_hss:D
\tex_vrule:D
}
}
\cs_new_protected:Npn \__graphics_include_auxiv:n #1
{
\hbox_set:Nn \l__graphics_internal_box
{
\exp_args:NnV \use:c { __graphics_backend_include_ #1 :n }
\l__graphics_name_tl
}
\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 }
\box_set_wd:Nn \l__graphics_internal_box
{ \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 }
\cs_new_protected:Npn \graphics_log_list: { \__graphics_list:N \msg_log:nnxxxx }
\cs_new_protected:Npn \__graphics_list:N #1
{
\seq_remove_duplicates:N \g__graphics_record_seq
#1 { LaTeX/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 }
\__kernel_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.
}
\__kernel_msg_new:nnnn { graphics } { pipe-failed }
{ Cannot~run~piped~system~commands. }
{
LaTeX~tried~to~call~a~system~process~but~this~was~not~possible.\\
Try~the~"--shell-escape"~(or~"--enable-pipes")~option.
}
\__kernel_msg_new:nnnn { graphics } { unsupported-graphic-type }
{ Image~type~'#1'~not~supported~by~current~driver. }
{
LaTeX~was~asked~to~include~an~graphic~of~type~'#1',~
but~this~is~not~supported~by~the~current~driver~(production~route).
}
%%
%%
%% End of file `l3graphics.sty'.