diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def | 133 |
1 files changed, 94 insertions, 39 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def index a8db92d73d0..5e1fe69f6fe 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def @@ -22,6 +22,66 @@ \ProvidesExplFile {l3pdfmode.def}{2017/03/18}{} {L3 Experimental driver: PDF mode} +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_new_protected:Npn \__driver_color_pickup: + { + \tl_set:Nx \l__color_current_tl + { + \exp_after:wN \__driver_color_pickup_aux:w + \current@color ~ 0 ~ 0 ~ 0 \q_stop + } + } + \cs_new:Npn \__driver_color_pickup_aux:w #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \q_stop + { + \str_if_eq:nnTF {#2} { g } + { gray ~ #1 } + { + \str_if_eq:nnTF {#4} { rg } + { rgb ~ #1 ~ #2 ~ #3 } + { + \str_if_eq:nnTF {#5} { k } + { cmyk ~ #1 ~ #2 ~ #3 ~ #4 } + { gray ~ #1 } + } + } + } + } + { \cs_new_protected:Npn \__driver_color_pickup: { } } + } +\int_new:N \l__driver_color_stack_int +\cs_new_protected:Npx \__driver_color_ensure_current: + { + \exp_not:N \__driver_color_pickup: + \cs_if_exist:NTF \luatex_pdfextension:D + { \luatex_pdfextension:D colorstack } + { \pdftex_pdfcolorstack:D } + \exp_not:N \l__driver_color_stack_int push + { + \exp_not:N \exp_after:wN + \exp_not:N \__driver_color_convert:w + \exp_not:N \l__color_current_tl + \c_space_tl 0 ~ 0 ~ 0 + \exp_not:N \q_stop + } + } +\cs_new:Npn \__driver_color_convert:w #1 ~ + { \use:c { __driver_color_convert_ #1 :w } } +\cs_new:Npn \__driver_color_convert_gray:w #1 ~ #2 \q_stop + { #1 ~ g ~ #1 ~ G } +\cs_new:Npn \__driver_color_convert_cmyk:w #1 ~ #2 ~ #3 ~ #4 \q_stop + { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } +\cs_new:Npn \__driver_color_convert_rgb:w #1 ~ #2 ~ #3 ~ #4 ~ #5 \q_stop + { #1 ~ #2 ~ #3 ~ #4 ~ k ~ #1 ~ #2 ~ #3 ~ #4 ~ K } +\cs_new_protected:Npx \__driver_color_reset: + { + \cs_if_exist:NTF \luatex_pdfextension:D + { \luatex_pdfextension:D colorstack } + { \pdftex_pdfcolorstack:D } + \exp_not:N \l__driver_color_stack_int pop \scan_stop: + } \cs_new_protected:Npx \__driver_literal:n #1 { \cs_if_exist:NTF \luatex_pdfextension:D @@ -101,82 +161,77 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } -\tl_new:N \l__driver_color_current_tl -\tl_set:Nn \l__driver_color_current_tl { 0~g~0~G } -\AtBeginDocument - { - \@ifpackageloaded { color } - { \tl_set:Nn \l__driver_color_current_tl { \current@color } } - { } - } -\int_new:N \l__driver_color_stack_int -\cs_new_protected:Npx \__driver_color_ensure_current: - { - \cs_if_exist:NTF \luatex_pdfextension:D - { \luatex_pdfextension:D colorstack } - { \pdftex_pdfcolorstack:D } - \exp_not:N \l__driver_color_stack_int push - { \exp_not:N \l__driver_color_current_tl } - \group_insert_after:N \exp_not:N \__driver_color_reset: - } -\cs_new_protected:Npx \__driver_color_reset: - { - \cs_if_exist:NTF \luatex_pdfextension:D - { \luatex_pdfextension:D colorstack } - { \pdftex_pdfcolorstack:D } - \exp_not:N \l__driver_color_stack_int pop \scan_stop: - } \tl_new:N \l__driver_image_attr_tl \cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 { \int_zero:N \l__image_page_int + \tl_clear:N \l__image_pagebox_tl \tl_set:Nx \l__driver_image_attr_tl { + \tl_if_empty:NF \l__image_decode_tl + { :D \l__image_decode_tl } \bool_if:NT \l__image_interpolate_bool { :I } } + \tl_clear:N \l__driver_image_attr_tl \__driver_image_getbb_auxi:n {#1} } \cs_new_eq:NN \__driver_image_getbb_png:n \__driver_image_getbb_jpg:n \cs_new_protected:Npn \__driver_image_getbb_pdf:n #1 { + \tl_clear:N \l__image_decode_tl \bool_set_false:N \l__image_interpolate_bool \tl_set:Nx \l__driver_image_attr_tl { - \int_compare:nNnT \l__image_page_int > 0 + : \l__image_pagebox_tl + \int_compare:nNnT \l__image_page_int > 1 { :P \int_use:N \l__image_page_int } } \__driver_image_getbb_auxi:n {#1} } \cs_new_protected:Npn \__driver_image_getbb_auxi:n #1 { - \dim_if_exist:cTF { c__image_ #1 \l__driver_image_attr_tl _ht_dim } + \dim_zero:N \l__image_llx_dim + \dim_zero:N \l__image_lly_dim + \dim_if_exist:cTF { c__image_ #1 \l__driver_image_attr_tl _urx_dim } { - \dim_set_eq:Nc \l__image_ht_dim - { c__image_ #1 \l__driver_image_attr_tl _ht_dim } - \dim_set_eq:Nc \l__image_wd_dim - { c__image_ #1 \l__driver_image_attr_tl _wd_dim } + \dim_set_eq:Nc \l__image_urx_dim + { c__image_ #1 \l__driver_image_attr_tl _urx_dim } + \dim_set_eq:Nc \l__image_ury_dim + { c__image_ #1 \l__driver_image_attr_tl _ury_dim } } { \__driver_image_getbb_auxii:n {#1} } } \cs_new_protected:Npn \__driver_image_getbb_auxii:n #1 { \tex_immediate:D \pdftex_pdfximage:D - \bool_if:NT \l__image_interpolate_bool - { attr ~ { /Interpolate~true } } + \bool_lazy_or:nnT + { \l__image_interpolate_bool } + { ! \tl_if_empty_p:N \l__image_decode_tl } + { + attr ~ + { + \tl_if_empty:NF \l__image_decode_tl + { /Decode~[ \l__image_decode_tl ] } + \bool_if:NT \l__image_interpolate_bool + { /Interpolate~true } + } + } \int_compare:nNnT \l__image_page_int > 0 { page ~ \int_use:N \l__image_page_int } + \tl_if_empty:NF \l__image_pagebox_tl + { \l__image_pagebox_tl } {#1} \hbox_set:Nn \l__image_tmp_box { \pdftex_pdfrefximage:D \pdftex_pdflastximage:D } - \dim_set:Nn \l__image_ht_dim { \box_ht:N \l__image_tmp_box } - \dim_set:Nn \l__image_wd_dim { \box_wd:N \l__image_tmp_box } + \dim_set:Nn \l__image_urx_dim { \box_wd:N \l__image_tmp_box } + \dim_set:Nn \l__image_ury_dim { \box_ht:N \l__image_tmp_box } \int_const:cn { c__image_ #1 \l__driver_image_attr_tl _int } { \tex_the:D \pdftex_pdflastximage:D } - \dim_const:cn { c__image_ #1 \l__driver_image_attr_tl _ht_dim } - { \l__image_ht_dim } - \dim_const:cn { c__image_ #1 \l__driver_image_attr_tl _wd_dim } - { \l__image_wd_dim } + \dim_const:cn { c__image_ #1 \l__driver_image_attr_tl _urx_dim } + { \l__image_urx_dim } + \dim_const:cn { c__image_ #1 \l__driver_image_attr_tl _ury_dim } + { \l__image_ury_dim } } \cs_new_protected:Npn \__driver_image_include_jpg:n #1 { |