| 1 |
%% |
| 2 |
%% This is file `latex-lab-testphase-graphic.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% latex-lab-graphic.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% Copyright 2021-2025 LaTeX Project |
| 12 |
%% |
| 13 |
%% This file was generated from file(s) of the `LaTeX-lab Bundle'. |
| 14 |
%% ------------------------------------------------------------------------------------ |
| 15 |
%% |
| 16 |
%% It may be distributed and/or modified under the |
| 17 |
%% conditions of the LaTeX Project Public License, either version 1.3c |
| 18 |
%% of this license or (at your option) any later version. |
| 19 |
%% The latest version of this license is in |
| 20 |
%% http://www.latex-project.org/lppl.txt |
| 21 |
%% and version 1.3c or later is part of all distributions of LaTeX |
| 22 |
%% version 2008 or later. |
| 23 |
%% |
| 24 |
%% This file may only be distributed together with a copy of the LaTeX |
| 25 |
%% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle' |
| 26 |
%% without such generated files. |
| 27 |
%% |
| 28 |
%% The newest sources can be found below |
| 29 |
%% |
| 30 |
%% https://github.com/latex3/latex2e/required/latex-lab |
| 31 |
%% |
| 32 |
%% where one can also log issues in case there are any. |
| 33 |
%% |
| 34 |
%% |
| 35 |
%% File: latex-lab-graphic.dtx (C) Copyright 2022-2025 LaTeX Project |
| 36 |
\def\ltlabgraphicdate{2025-09-25} |
| 37 |
\def\ltlabgraphicversion{0.80i} |
| 38 |
|
| 39 |
\ProvidesExplPackage {latex-lab-testphase-graphic} {\ltlabgraphicdate} {\ltlabgraphicversion} |
| 40 |
{Code related to the tagging of graphics} |
| 41 |
\cs_generate_variant:Nn \tag_socket_use:nn {ne} |
| 42 |
\cs_if_exist:NF \opacity_select:n |
| 43 |
{ |
| 44 |
\RequirePackage{l3opacity} |
| 45 |
} |
| 46 |
\cs_new_protected:Npn\__tag_graphic_savepos:n #1 |
| 47 |
{ |
| 48 |
\tex_savepos:D |
| 49 |
\property_record:nn{#1}{xpos,ypos,abspage} |
| 50 |
\tex_savepos:D |
| 51 |
} |
| 52 |
\cs_generate_variant:Nn \__tag_graphic_savepos:n {e} |
| 53 |
\tl_new:N \l__tag_graphic_alt_tl |
| 54 |
\tl_new:N \l__tag_graphic_actual_tl |
| 55 |
\tl_new:N \l__tag_graphic_struct_tl |
| 56 |
\tl_set:Nn\l__tag_graphic_struct_tl {Figure} |
| 57 |
\bool_new:N \l__tag_graphic_debug_bool |
| 58 |
\int_new:N\g__tag_graphic_int |
| 59 |
|
| 60 |
\tl_new:N \g__tag_graphic_lx_tl |
| 61 |
\tl_new:N \g__tag_graphic_ly_tl |
| 62 |
\tl_new:N \g__tag_graphic_ux_tl |
| 63 |
\tl_new:N \g__tag_graphic_uy_tl |
| 64 |
\seq_new:N\l__tag_graphic_bboxcorr_seq |
| 65 |
\bool_new:N\l__tag_graphic_bboxcorr_bool |
| 66 |
\tl_new:N \l__tag_graphic_currentlabel_tl |
| 67 |
\fp_new:N\l__tag_graphic_sin_fp |
| 68 |
\fp_new:N\l__tag_graphic_cos_fp |
| 69 |
\fp_new:N\l__tag_graphic_lxly_fp |
| 70 |
\fp_new:N\l__tag_graphic_lxuy_fp |
| 71 |
\fp_new:N\l__tag_graphic_uxly_fp |
| 72 |
\fp_new:N\l__tag_graphic_uxuy_fp |
| 73 |
\fp_new:N\l__tag_graphic_ux_fp |
| 74 |
\fp_new:N\l__tag_graphic_ly_fp |
| 75 |
\fp_new:N\l__tag_graphic_lx_fp |
| 76 |
\fp_new:N\l__tag_graphic_uy_fp |
| 77 |
\fp_new:N\l__tag_graphic_scale_fp |
| 78 |
\fp_new:N\l__tag_graphic_trim_ux_fp |
| 79 |
\fp_new:N\l__tag_graphic_trim_ly_fp |
| 80 |
\fp_new:N\l__tag_graphic_trim_lx_fp |
| 81 |
\fp_new:N\l__tag_graphic_trim_uy_fp |
| 82 |
\NewTaggingSocket{graphic/init}{1} |
| 83 |
\NewTaggingSocket{graphic/begin}{1} |
| 84 |
\NewTaggingSocket{graphic/end}{2} |
| 85 |
\NewTaggingSocket{graphic/text/begin}{0} |
| 86 |
\NewTaggingSocket{graphic/text/end}{0} |
| 87 |
\NewTaggingSocketPlug{graphic/init}{default} |
| 88 |
{ |
| 89 |
\keys_set:nn{tag/graphic}{#1} |
| 90 |
\ExpandArgs{no}\AssignTaggingSocketPlug{graphic/begin}{\l_tag_graphic_mode_tl} |
| 91 |
\ExpandArgs{no}\AssignTaggingSocketPlug{graphic/end}{\l_tag_graphic_mode_tl} |
| 92 |
} |
| 93 |
\AssignTaggingSocketPlug{graphic/init}{default} |
| 94 |
\msg_new:nnn { tag } { alt-text-missing } |
| 95 |
{ |
| 96 |
Alternative~text~for~graphic~is~missing.\\ |
| 97 |
Using~'#1'~instead. |
| 98 |
} |
| 99 |
\NewTaggingSocketPlug{graphic/begin}{alt} |
| 100 |
{ |
| 101 |
\tag_mc_end_push: |
| 102 |
\tl_if_empty:NT\l__tag_graphic_alt_tl |
| 103 |
{ |
| 104 |
\msg_warning:nne{tag}{alt-text-missing}{#1} |
| 105 |
\tl_set:Ne\l__tag_graphic_alt_tl {\text_purify:n{#1}} |
| 106 |
} |
| 107 |
\tag_struct_begin:n |
| 108 |
{ |
| 109 |
tag=\l__tag_graphic_struct_tl, |
| 110 |
alt=\l__tag_graphic_alt_tl, |
| 111 |
} |
| 112 |
\tag_mc_begin:n{} |
| 113 |
} |
| 114 |
\NewTaggingSocketPlug{graphic/end}{alt} |
| 115 |
{ |
| 116 |
#1 |
| 117 |
#2 |
| 118 |
\tag_mc_end: |
| 119 |
\tag_struct_end: |
| 120 |
\tag_mc_begin_pop:n{} |
| 121 |
} |
| 122 |
\NewTaggingSocketPlug{graphic/begin}{actualtext} |
| 123 |
{ |
| 124 |
\tag_mc_end_push: |
| 125 |
\tag_struct_begin:n{tag=Span,actualtext=\l__tag_graphic_actual_tl } |
| 126 |
\tag_mc_begin:n{} |
| 127 |
} |
| 128 |
\NewTaggingSocketPlug{graphic/end}{actualtext} |
| 129 |
{ |
| 130 |
#2 |
| 131 |
\tag_mc_end: |
| 132 |
\tag_struct_end: |
| 133 |
\tag_mc_begin_pop:n{} |
| 134 |
} |
| 135 |
\NewTaggingSocketPlug{graphic/begin}{artifact} |
| 136 |
{ |
| 137 |
\tag_mc_end_push: |
| 138 |
\tag_mc_begin:n{artifact} |
| 139 |
} |
| 140 |
\NewTaggingSocketPlug{graphic/end}{artifact} |
| 141 |
{ |
| 142 |
#2 |
| 143 |
\tag_mc_end: |
| 144 |
\tag_mc_begin_pop:n{} |
| 145 |
} |
| 146 |
\NewTaggingSocketPlug{graphic/begin}{text} |
| 147 |
{ |
| 148 |
\tag_mc_end_push: |
| 149 |
\tag_mc_begin:n{artifact} |
| 150 |
} |
| 151 |
\NewTaggingSocketPlug{graphic/end}{text} |
| 152 |
{ |
| 153 |
#2 |
| 154 |
\tag_mc_end: |
| 155 |
\tag_mc_begin_pop:n{} |
| 156 |
} |
| 157 |
\NewTaggingSocketPlug{graphic/begin}{off}{} |
| 158 |
\NewTaggingSocketPlug{graphic/end}{off}{#2} |
| 159 |
|
| 160 |
\AssignTaggingSocketPlug{graphic/begin}{alt} |
| 161 |
\AssignTaggingSocketPlug{graphic/end}{alt} |
| 162 |
\NewTaggingSocketPlug{graphic/text/begin}{default} |
| 163 |
{ |
| 164 |
\tag_mc_end: |
| 165 |
\tag_mc_begin:n{} |
| 166 |
} |
| 167 |
\NewTaggingSocketPlug{graphic/text/end}{default} |
| 168 |
{ |
| 169 |
\tag_mc_end: |
| 170 |
\tag_mc_begin:n{artifact} |
| 171 |
} |
| 172 |
\AssignTaggingSocketPlug{graphic/text/begin}{default} |
| 173 |
\AssignTaggingSocketPlug{graphic/text/end}{default} |
| 174 |
\keys_define:nn{tag/graphic} |
| 175 |
{ |
| 176 |
,mode .code:n = |
| 177 |
{ |
| 178 |
\tl_set:Ne\l_tag_graphic_mode_tl{#1} |
| 179 |
} |
| 180 |
,alt .code:n = |
| 181 |
{ |
| 182 |
\tl_set:Ne\l__tag_graphic_alt_tl{\text_purify:n{#1}} |
| 183 |
\tl_set:Nn\l_tag_graphic_mode_tl{alt} |
| 184 |
} |
| 185 |
,artifact .code:n = |
| 186 |
{ |
| 187 |
\tl_set:Nn\l_tag_graphic_mode_tl{artifact} |
| 188 |
} |
| 189 |
,actualtext .code:n = |
| 190 |
{ |
| 191 |
\tl_set:Ne\l__tag_graphic_actual_tl{\text_purify:n{#1}} |
| 192 |
\tl_set:Nn\l_tag_graphic_mode_tl{actualtext} |
| 193 |
} |
| 194 |
,text .code:n = |
| 195 |
{ |
| 196 |
\tl_set:Nn\l_tag_graphic_mode_tl{text} |
| 197 |
} |
| 198 |
,off .code:n = |
| 199 |
{ |
| 200 |
\tl_set:Nn\l_tag_graphic_mode_tl{off} |
| 201 |
} |
| 202 |
,adjust-BBox .code:n = |
| 203 |
{ |
| 204 |
\bool_set_true:N \l__tag_graphic_bboxcorr_bool |
| 205 |
\seq_set_split:Nnn\l__tag_graphic_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt} |
| 206 |
} |
| 207 |
, |
| 208 |
tagging-setup .code:n= |
| 209 |
{ |
| 210 |
\keys_set:nn { tag/graphic }{#1} |
| 211 |
} |
| 212 |
,tag .code:n = |
| 213 |
{ |
| 214 |
\str_case:nnF {#1} |
| 215 |
{ |
| 216 |
{artifact} |
| 217 |
{ |
| 218 |
\tl_set:Nn\l_tag_graphic_mode_tl{artifact} |
| 219 |
} |
| 220 |
{false}{\tag_suspend:n{picture}} |
| 221 |
} |
| 222 |
{ |
| 223 |
\tl_set:Nn\l__tag_graphic_struct_tl{#1} |
| 224 |
\tl_set:Nn\l_tag_graphic_mode_tl{alt} |
| 225 |
} |
| 226 |
} |
| 227 |
} |
| 228 |
\tl_new:N \l_tag_graphic_mode_tl |
| 229 |
\tl_set:Nn \l_tag_graphic_mode_tl {alt} %TODO think about the right default. |
| 230 |
\hook_new_with_args:nn {Gin/alt} {2} |
| 231 |
\hook_new:n {Gin/artifact} |
| 232 |
\hook_new_with_args:nn {Gin/actualtext}{2} |
| 233 |
\AddToHook{package/graphicx/after}[latex-lab] |
| 234 |
{ |
| 235 |
\define@key{Gin}{alt} |
| 236 |
{ |
| 237 |
\tl_set:Ne\l__tag_graphic_alt_tl{\text_purify:n{#1}} |
| 238 |
\exp_args:Nnno\hook_use:nnw {Gin/alt}{2}{\l__tag_graphic_alt_tl}{#1} |
| 239 |
\tl_set:Nn\l_tag_graphic_mode_tl {alt} |
| 240 |
} |
| 241 |
\define@key{Gin}{artifact}[] |
| 242 |
{ |
| 243 |
\hook_use:n{Gin/artifact} |
| 244 |
\tl_set:Nn\l_tag_graphic_mode_tl{artifact} |
| 245 |
} |
| 246 |
\define@key{Gin}{actualtext} |
| 247 |
{ |
| 248 |
\tl_set:Ne\l__tag_graphic_actual_tl{\text_purify:n{#1}} |
| 249 |
\exp_args:Nnno\hook_use:nnw {Gin/actualtext}{1}{\l__tag_graphic_actual_tl}{#1} |
| 250 |
\tl_set:Nn\l_tag_graphic_mode_tl{actualtext} |
| 251 |
} |
| 252 |
\define@key{Gin}{tagging-setup} |
| 253 |
{ |
| 254 |
\keys_set:nn { tag/graphic}{#1} |
| 255 |
} |
| 256 |
\define@key{Gin}{adjust-BBox} |
| 257 |
{ |
| 258 |
\bool_set_true:N \l__tag_graphic_bboxcorr_bool |
| 259 |
\seq_set_split:Nnn\l__tag_graphic_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt} |
| 260 |
} |
| 261 |
\define@key{Gin}{tag} |
| 262 |
{ |
| 263 |
\str_case:nnF {#1} |
| 264 |
{ |
| 265 |
{artifact} |
| 266 |
{ |
| 267 |
\tl_set:Nn\l_tag_graphic_mode_tl{artifact} |
| 268 |
} |
| 269 |
{false}{\tag_suspend:n{Gin}} |
| 270 |
} |
| 271 |
{ |
| 272 |
\tl_set:Nn\l__tag_graphic_struct_tl{#1} |
| 273 |
\tl_set:Nn\l_tag_graphic_mode_tl{alt} |
| 274 |
} |
| 275 |
} |
| 276 |
} |
| 277 |
\AddToHook{package/graphics/after}[latex-lab] |
| 278 |
{\RequirePackage{graphicx}} |
| 279 |
\AddToHook{package/graphics/after} |
| 280 |
{ |
| 281 |
\def\Gin@setfile#1#2#3{% |
| 282 |
\ifx\\#2\\\Gread@false\fi |
| 283 |
\ifGin@bbox\else |
| 284 |
\ifGread@ |
| 285 |
\csname Gread@% |
| 286 |
\expandafter\ifx\csname Gread@#1\endcsname\relax |
| 287 |
eps% |
| 288 |
\else |
| 289 |
#1% |
| 290 |
\fi |
| 291 |
\endcsname{\Gin@base#2}% |
| 292 |
\else |
| 293 |
\Gin@nosize{#3}% |
| 294 |
\fi |
| 295 |
\fi |
| 296 |
\Gin@viewport@code |
| 297 |
\Gin@nat@height\Gin@ury bp% |
| 298 |
\advance\Gin@nat@height-\Gin@lly bp% |
| 299 |
\Gin@nat@width\Gin@urx bp% |
| 300 |
\advance\Gin@nat@width-\Gin@llx bp% |
| 301 |
\Gin@req@sizes |
| 302 |
\expandafter\ifx\csname Ginclude@#1\endcsname\relax |
| 303 |
\Gin@drafttrue |
| 304 |
\expandafter\ifx\csname Gread@#1\endcsname\relax |
| 305 |
\@latex@error{Can not include graphics of type: #1}\@ehc |
| 306 |
\global\expandafter\let\csname Gread@#1\endcsname\@empty |
| 307 |
\fi |
| 308 |
\fi |
| 309 |
\leavevmode |
| 310 |
\tag_socket_use:ne {graphic/init} {tagging-setup={mode=\l_tag_graphic_mode_tl}} |
| 311 |
\tag_socket_use:nn {graphic/begin} {\Gin@base\Gin@ext} |
| 312 |
\ifGin@draft |
| 313 |
\setbox\z@ |
| 314 |
\hb@xt@\Gin@req@width{% |
| 315 |
\vrule\hss |
| 316 |
\vbox to \Gin@req@height{% |
| 317 |
\hrule \@width \Gin@req@width |
| 318 |
\vss |
| 319 |
\edef\@tempa{#3}% |
| 320 |
\rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}% |
| 321 |
\vss |
| 322 |
\hrule}% |
| 323 |
\hss\vrule}% |
| 324 |
\else |
| 325 |
\@addtofilelist{#3}% |
| 326 |
\ProvidesFile{#3}[Graphic~file~(type~#1)]% |
| 327 |
\setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}% |
| 328 |
\dp\z@\z@ |
| 329 |
\ht\z@\Gin@req@height |
| 330 |
\wd\z@\Gin@req@width |
| 331 |
\fi |
| 332 |
\tag_socket_use:nnn{graphic/end} |
| 333 |
{ \Gin@tag@bbox@attribute } |
| 334 |
{ \box\z@ } |
| 335 |
} |
| 336 |
} |
| 337 |
\cs_new_protected:Npn \__tag_graphic_get_trim: |
| 338 |
{ |
| 339 |
\legacy_if:nTF {Gin@clip} |
| 340 |
{ |
| 341 |
\fp_zero:N\l__tag_graphic_trim_lx_fp |
| 342 |
\fp_zero:N\l__tag_graphic_trim_ly_fp |
| 343 |
\fp_zero:N\l__tag_graphic_trim_ux_fp |
| 344 |
\fp_zero:N\l__tag_graphic_trim_uy_fp |
| 345 |
} |
| 346 |
{ |
| 347 |
\fp_set:Nn \l__tag_graphic_trim_lx_fp {\l__tag_graphic_scale_fp*\Gin@vllx} |
| 348 |
\fp_set:Nn \l__tag_graphic_trim_ly_fp {\l__tag_graphic_scale_fp*\Gin@vlly} |
| 349 |
\fp_set:Nn \l__tag_graphic_trim_ux_fp {\l__tag_graphic_scale_fp*\Gin@vurx} |
| 350 |
\fp_set:Nn \l__tag_graphic_trim_uy_fp {\l__tag_graphic_scale_fp*\Gin@vury} |
| 351 |
\cs_if_exist:NT \Gin@ollx |
| 352 |
{ |
| 353 |
\fp_set:Nn \l__tag_graphic_trim_ux_fp {\l__tag_graphic_scale_fp* (\Gin@ourx-(\Gin@urx)) } |
| 354 |
\fp_set:Nn \l__tag_graphic_trim_uy_fp {\l__tag_graphic_scale_fp* (\Gin@oury-(\Gin@ury)) } |
| 355 |
} |
| 356 |
} |
| 357 |
} |
| 358 |
\cs_new_protected:Npn \__tag_graphic_get_scale: |
| 359 |
{ |
| 360 |
\fp_set:Nn \l__tag_graphic_scale_fp |
| 361 |
{ |
| 362 |
\str_if_eq:eeTF {\Gin@scalex} { ! } |
| 363 |
{ \Gin@scaley } |
| 364 |
{ \Gin@scalex } |
| 365 |
} |
| 366 |
} |
| 367 |
\cs_new_protected:Npn \__tag_graphic_applyangle:nnnn #1#2#3#4 %lx,ly,ux,uy |
| 368 |
{ |
| 369 |
\bool_lazy_and:nnT |
| 370 |
{\cs_if_exist_p:N \Grot@angle } |
| 371 |
{! \int_compare_p:nNn { \Grot@angle }={0}} |
| 372 |
{ |
| 373 |
\fp_set:Nn \l__tag_graphic_sin_fp { sind(\Grot@angle) } |
| 374 |
\fp_set:Nn \l__tag_graphic_cos_fp { cosd(\Grot@angle) } |
| 375 |
\fp_set:Nn \l__tag_graphic_lx_fp {#1} |
| 376 |
\fp_set:Nn \l__tag_graphic_ly_fp {#2} |
| 377 |
\fp_set:Nn \l__tag_graphic_ux_fp {#3} |
| 378 |
\fp_set:Nn \l__tag_graphic_uy_fp {#4} |
| 379 |
\fp_set:Nn\l__tag_graphic_lxly_fp |
| 380 |
{ |
| 381 |
-\l__tag_graphic_trim_lx_fp * \l__tag_graphic_cos_fp |
| 382 |
+\l__tag_graphic_trim_ly_fp * \l__tag_graphic_sin_fp |
| 383 |
} |
| 384 |
\fp_set:Nn\l__tag_graphic_lxuy_fp |
| 385 |
{ |
| 386 |
(-\l__tag_graphic_trim_lx_fp) * \l__tag_graphic_cos_fp |
| 387 |
+ |
| 388 |
(\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) |
| 389 |
* (-\l__tag_graphic_sin_fp) |
| 390 |
} |
| 391 |
\fp_set:Nn\l__tag_graphic_uxly_fp |
| 392 |
{ |
| 393 |
(\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) |
| 394 |
* \l__tag_graphic_cos_fp |
| 395 |
+ |
| 396 |
(\l__tag_graphic_trim_ly_fp) * (\l__tag_graphic_sin_fp) |
| 397 |
} |
| 398 |
\fp_set:Nn\l__tag_graphic_uxuy_fp |
| 399 |
{ |
| 400 |
(\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) |
| 401 |
* \l__tag_graphic_cos_fp |
| 402 |
+ |
| 403 |
(\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) |
| 404 |
* (-\l__tag_graphic_sin_fp) |
| 405 |
} |
| 406 |
\tl_gset:Ne\g__tag_graphic_lx_tl |
| 407 |
{ |
| 408 |
\fp_eval:n |
| 409 |
{ |
| 410 |
min |
| 411 |
( |
| 412 |
\l__tag_graphic_lxly_fp, |
| 413 |
\l__tag_graphic_lxuy_fp, |
| 414 |
\l__tag_graphic_uxly_fp, |
| 415 |
\l__tag_graphic_uxuy_fp, |
| 416 |
) |
| 417 |
+\l__tag_graphic_lx_fp |
| 418 |
+\l__tag_graphic_trim_lx_fp |
| 419 |
} |
| 420 |
} |
| 421 |
\tl_gset:Ne\g__tag_graphic_ux_tl |
| 422 |
{ |
| 423 |
\fp_eval:n |
| 424 |
{ |
| 425 |
max |
| 426 |
( |
| 427 |
\l__tag_graphic_lxly_fp, |
| 428 |
\l__tag_graphic_lxuy_fp, |
| 429 |
\l__tag_graphic_uxly_fp, |
| 430 |
\l__tag_graphic_uxuy_fp |
| 431 |
) |
| 432 |
+\l__tag_graphic_lx_fp |
| 433 |
+\l__tag_graphic_trim_lx_fp |
| 434 |
} |
| 435 |
} |
| 436 |
\fp_set:Nn\l__tag_graphic_lxly_fp |
| 437 |
{ |
| 438 |
-\l__tag_graphic_trim_lx_fp * \l__tag_graphic_sin_fp |
| 439 |
-\l__tag_graphic_trim_ly_fp * \l__tag_graphic_cos_fp |
| 440 |
} |
| 441 |
\fp_set:Nn\l__tag_graphic_lxuy_fp |
| 442 |
{ |
| 443 |
- \l__tag_graphic_trim_lx_fp * \l__tag_graphic_sin_fp |
| 444 |
+ |
| 445 |
(\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) |
| 446 |
* \l__tag_graphic_cos_fp |
| 447 |
} |
| 448 |
\fp_set:Nn\l__tag_graphic_uxly_fp |
| 449 |
{ |
| 450 |
(\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) |
| 451 |
* \l__tag_graphic_sin_fp |
| 452 |
- \l__tag_graphic_trim_ly_fp * \l__tag_graphic_cos_fp |
| 453 |
} |
| 454 |
\fp_set:Nn\l__tag_graphic_uxuy_fp |
| 455 |
{ |
| 456 |
(\l__tag_graphic_ux_fp-\l__tag_graphic_lx_fp-\l__tag_graphic_trim_lx_fp) |
| 457 |
* \l__tag_graphic_sin_fp |
| 458 |
+ |
| 459 |
(\l__tag_graphic_uy_fp-\l__tag_graphic_ly_fp-\l__tag_graphic_trim_ly_fp) |
| 460 |
* \l__tag_graphic_cos_fp |
| 461 |
} |
| 462 |
\tl_gset:Ne\g__tag_graphic_ly_tl |
| 463 |
{ |
| 464 |
\fp_eval:n |
| 465 |
{ |
| 466 |
min |
| 467 |
( |
| 468 |
\l__tag_graphic_lxly_fp, |
| 469 |
\l__tag_graphic_lxuy_fp, |
| 470 |
\l__tag_graphic_uxly_fp, |
| 471 |
\l__tag_graphic_uxuy_fp |
| 472 |
) |
| 473 |
+ \l__tag_graphic_ly_fp + \l__tag_graphic_trim_ly_fp |
| 474 |
} |
| 475 |
} |
| 476 |
\tl_gset:Ne\g__tag_graphic_uy_tl |
| 477 |
{ |
| 478 |
\fp_eval:n |
| 479 |
{ |
| 480 |
max |
| 481 |
( |
| 482 |
\l__tag_graphic_lxly_fp, |
| 483 |
\l__tag_graphic_lxuy_fp, |
| 484 |
\l__tag_graphic_uxly_fp, |
| 485 |
\l__tag_graphic_uxuy_fp, |
| 486 |
) |
| 487 |
+ \l__tag_graphic_ly_fp + \l__tag_graphic_trim_ly_fp |
| 488 |
} |
| 489 |
} |
| 490 |
} |
| 491 |
} |
| 492 |
\cs_generate_variant:Nn\__tag_graphic_applyangle:nnnn {VVVV} |
| 493 |
\cs_new_protected:Npn \__tag_graphic_applycorr:NNNN #1 #2 #3 #4 |
| 494 |
{ |
| 495 |
\bool_if:NT\l__tag_graphic_bboxcorr_bool |
| 496 |
{ |
| 497 |
\tl_set:Ne #1 |
| 498 |
{ |
| 499 |
\fp_eval:n |
| 500 |
{ |
| 501 |
#1 |
| 502 |
+ |
| 503 |
\dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {1} } |
| 504 |
} |
| 505 |
} |
| 506 |
\tl_set:Ne #2 |
| 507 |
{ |
| 508 |
\fp_eval:n |
| 509 |
{ |
| 510 |
#2 |
| 511 |
+ |
| 512 |
\dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {2} } |
| 513 |
} |
| 514 |
} |
| 515 |
\tl_set:Ne #3 |
| 516 |
{ |
| 517 |
\fp_eval:n |
| 518 |
{ |
| 519 |
#3 |
| 520 |
+ |
| 521 |
\dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {3} } |
| 522 |
} |
| 523 |
} |
| 524 |
\tl_set:Ne #4 |
| 525 |
{ |
| 526 |
\fp_eval:n |
| 527 |
{ |
| 528 |
#4 |
| 529 |
+ |
| 530 |
\dim_to_decimal_in_bp:n {\seq_item:Nn \l__tag_graphic_bboxcorr_seq {4} } |
| 531 |
} |
| 532 |
} |
| 533 |
} |
| 534 |
} |
| 535 |
\cs_new_protected:Npn \Gin@tag@bbox@attribute |
| 536 |
{ |
| 537 |
\__tag_graphic_get_scale: |
| 538 |
\__tag_graphic_get_trim: |
| 539 |
\int_gincr:N\g__tag_graphic_int |
| 540 |
\tl_set:Ne\l__tag_graphic_currentlabel_tl {__tag_graphic.\int_use:N \g__tag_graphic_int} |
| 541 |
\__tag_graphic_savepos:e { \l__tag_graphic_currentlabel_tl } |
| 542 |
\tl_gset:Ne\g__tag_graphic_lx_tl |
| 543 |
{ |
| 544 |
\dim_to_decimal_in_bp:n |
| 545 |
{ \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp } |
| 546 |
} |
| 547 |
\tl_gset:Ne\g__tag_graphic_ly_tl |
| 548 |
{ |
| 549 |
\dim_to_decimal_in_bp:n |
| 550 |
{ \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp } |
| 551 |
} |
| 552 |
\tl_gset:Ne\g__tag_graphic_ux_tl |
| 553 |
{ |
| 554 |
\fp_eval:n |
| 555 |
{ |
| 556 |
\g__tag_graphic_lx_tl |
| 557 |
+ |
| 558 |
\dim_to_decimal_in_bp:n { \Gin@req@width } |
| 559 |
} |
| 560 |
} |
| 561 |
\tl_gset:Ne\g__tag_graphic_uy_tl |
| 562 |
{ |
| 563 |
\fp_eval:n |
| 564 |
{ |
| 565 |
\g__tag_graphic_ly_tl |
| 566 |
+ |
| 567 |
\dim_to_decimal_in_bp:n { \Gin@req@height } |
| 568 |
} |
| 569 |
} |
| 570 |
\legacy_if:nF {Gin@clip} |
| 571 |
{ |
| 572 |
\tl_gset:Ne\g__tag_graphic_ux_tl |
| 573 |
{ |
| 574 |
\fp_eval:n |
| 575 |
{ |
| 576 |
\g__tag_graphic_ux_tl |
| 577 |
+ |
| 578 |
\l__tag_graphic_trim_ux_fp |
| 579 |
} |
| 580 |
} |
| 581 |
\tl_gset:Ne\g__tag_graphic_lx_tl |
| 582 |
{ |
| 583 |
\fp_eval:n |
| 584 |
{ |
| 585 |
\g__tag_graphic_lx_tl |
| 586 |
- |
| 587 |
\l__tag_graphic_trim_lx_fp |
| 588 |
} |
| 589 |
} |
| 590 |
\tl_gset:Ne\g__tag_graphic_uy_tl |
| 591 |
{ |
| 592 |
\fp_eval:n |
| 593 |
{ |
| 594 |
\g__tag_graphic_uy_tl |
| 595 |
+ |
| 596 |
\l__tag_graphic_trim_uy_fp |
| 597 |
} |
| 598 |
} |
| 599 |
\tl_gset:Ne\g__tag_graphic_ly_tl |
| 600 |
{ |
| 601 |
\fp_eval:n |
| 602 |
{ |
| 603 |
\g__tag_graphic_ly_tl |
| 604 |
- |
| 605 |
\l__tag_graphic_trim_ly_fp |
| 606 |
} |
| 607 |
} |
| 608 |
} |
| 609 |
\__tag_graphic_applyangle:VVVV |
| 610 |
\g__tag_graphic_lx_tl |
| 611 |
\g__tag_graphic_ly_tl |
| 612 |
\g__tag_graphic_ux_tl |
| 613 |
\g__tag_graphic_uy_tl |
| 614 |
\__tag_graphic_applycorr:NNNN |
| 615 |
\g__tag_graphic_lx_tl |
| 616 |
\g__tag_graphic_ly_tl |
| 617 |
\g__tag_graphic_ux_tl |
| 618 |
\g__tag_graphic_uy_tl |
| 619 |
\bool_if:NT\l__tag_graphic_debug_bool |
| 620 |
{ |
| 621 |
\__tag_graphic_show_bbox:VVVVne |
| 622 |
\g__tag_graphic_lx_tl |
| 623 |
\g__tag_graphic_ly_tl |
| 624 |
\g__tag_graphic_ux_tl |
| 625 |
\g__tag_graphic_uy_tl |
| 626 |
{red} |
| 627 |
{\l__tag_graphic_currentlabel_tl} |
| 628 |
} |
| 629 |
\tag_struct_gput:ene{\tag_get:n{struct_num}}{attribute} |
| 630 |
{ |
| 631 |
/O /Layout /BBox~ |
| 632 |
[ |
| 633 |
\g__tag_graphic_lx_tl\c_space_tl |
| 634 |
\g__tag_graphic_ly_tl\c_space_tl |
| 635 |
\g__tag_graphic_ux_tl\c_space_tl |
| 636 |
\g__tag_graphic_uy_tl |
| 637 |
] |
| 638 |
} |
| 639 |
} |
| 640 |
\newcommand\picture@tag@bbox@attribute |
| 641 |
{ |
| 642 |
\int_gincr:N\g__tag_graphic_int |
| 643 |
\tl_set:Ne\l__tag_graphic_currentlabel_tl {__tag_graphic.\int_use:N \g__tag_graphic_int} |
| 644 |
\__tag_graphic_savepos:e { \l__tag_graphic_currentlabel_tl } |
| 645 |
\tl_gset:Ne \g__tag_graphic_lx_tl |
| 646 |
{ |
| 647 |
\dim_to_decimal_in_bp:n |
| 648 |
{ \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp } |
| 649 |
} |
| 650 |
\tl_gset:Ne \g__tag_graphic_ly_tl |
| 651 |
{ |
| 652 |
\dim_to_decimal_in_bp:n |
| 653 |
{ \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp - \dp\@picbox } |
| 654 |
} |
| 655 |
\tl_gset:Ne \g__tag_graphic_ux_tl |
| 656 |
{ |
| 657 |
\dim_to_decimal_in_bp:n |
| 658 |
{ |
| 659 |
\g__tag_graphic_lx_tl bp + \wd\@picbox |
| 660 |
} |
| 661 |
} |
| 662 |
\tl_gset:Ne \g__tag_graphic_uy_tl |
| 663 |
{ |
| 664 |
\dim_to_decimal_in_bp:n |
| 665 |
{ |
| 666 |
\g__tag_graphic_ly_tl bp + \ht\@picbox + \dp\@picbox |
| 667 |
} |
| 668 |
} |
| 669 |
\__tag_graphic_applycorr:NNNN |
| 670 |
\g__tag_graphic_lx_tl |
| 671 |
\g__tag_graphic_ly_tl |
| 672 |
\g__tag_graphic_ux_tl |
| 673 |
\g__tag_graphic_uy_tl |
| 674 |
\bool_if:NT\l__tag_graphic_debug_bool |
| 675 |
{ |
| 676 |
\__tag_graphic_show_bbox:VVVVne |
| 677 |
\g__tag_graphic_lx_tl |
| 678 |
\g__tag_graphic_ly_tl |
| 679 |
\g__tag_graphic_ux_tl |
| 680 |
\g__tag_graphic_uy_tl |
| 681 |
{red} |
| 682 |
{\l__tag_graphic_currentlabel_tl} |
| 683 |
} |
| 684 |
\tag_struct_gput:ene{\tag_get:n{struct_num}}{attribute} |
| 685 |
{ |
| 686 |
/O /Layout /BBox~ |
| 687 |
[ |
| 688 |
\g__tag_graphic_lx_tl\c_space_tl |
| 689 |
\g__tag_graphic_ly_tl\c_space_tl |
| 690 |
\g__tag_graphic_ux_tl\c_space_tl |
| 691 |
\g__tag_graphic_uy_tl |
| 692 |
] |
| 693 |
} |
| 694 |
} |
| 695 |
\RenewDocumentCommand\picture{O{}m} |
| 696 |
{ |
| 697 |
\leavevmode |
| 698 |
\tag_socket_use:nn{graphic/init}{#1} |
| 699 |
\pictur@#2 |
| 700 |
} |
| 701 |
\def\@picture(#1,#2)(#3,#4){% |
| 702 |
\@defaultunitsset\@picht{#2}\unitlength |
| 703 |
\@defaultunitsset\@tempdimc{#1}\unitlength |
| 704 |
\tag_socket_use:nn{graphic/begin}{picture~environment} |
| 705 |
\tag_suspend:n{\@picture} %do not tag inside the picture box |
| 706 |
\setbox\@picbox\hb@xt@\@tempdimc\bgroup |
| 707 |
\@defaultunitsset\@tempdimc{#3}\unitlength |
| 708 |
\hskip -\@tempdimc |
| 709 |
\@defaultunitsset\@tempdimc{#4}\unitlength |
| 710 |
\lower\@tempdimc\hbox\bgroup |
| 711 |
\ignorespaces} |
| 712 |
\def\endpicture{% |
| 713 |
\egroup\hss\egroup |
| 714 |
\ht\@picbox\@picht\dp\@picbox\z@ |
| 715 |
\tag_resume:n{\@picture} |
| 716 |
\tag_socket_use:nnn{graphic/end} |
| 717 |
{\picture@tag@bbox@attribute} |
| 718 |
{\mbox{\box\@picbox}}} |
| 719 |
\cs_new_protected:Npn \__tag_graphic_show_bbox:nnnnnn #1#2#3#4#5#6%#5 color, #6 label name |
| 720 |
{ |
| 721 |
\iow_log:n {tag/graphic~debug:~BBox~of~graphics~#6~is~#1~#2~#3~#4} |
| 722 |
\hook_gput_code:nnn |
| 723 |
{shipout/foreground} |
| 724 |
{tag/graphic} |
| 725 |
{ |
| 726 |
\int_compare:nNnT |
| 727 |
{\g_shipout_readonly_int} |
| 728 |
= |
| 729 |
{\property_ref:een{#6}{abspage}{0}} |
| 730 |
{ |
| 731 |
\put |
| 732 |
(#1 bp,\dim_eval:n{-\paperheight + \dim_eval:n{#2 bp}}) |
| 733 |
{ |
| 734 |
\opacity_select:n{0.5}\color_select:n{#5} |
| 735 |
\rule |
| 736 |
{\dim_eval:n {#3 bp-\dim_eval:n{#1 bp}}} |
| 737 |
{\dim_eval:n {#4 bp-\dim_eval:n{#2 bp}}} |
| 738 |
} |
| 739 |
} |
| 740 |
} |
| 741 |
} |
| 742 |
\cs_generate_variant:Nn \__tag_graphic_show_bbox:nnnnnn {VVVVne,nnnnne} |
| 743 |
|
| 744 |
|
| 745 |
\endinput |
| 746 |
%% |
| 747 |
%% End of file `latex-lab-testphase-graphic.sty'. |