1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21\writestatus{loading}{ConTeXt Graphic Macros Figure Inclusion}
22
23\registerctxluafile{grphimg}{}
24\registerctxluafile{grphinc}{autosuffix}
25\registerctxluafile{grphbmp}{}
26\registerctxluafile{grphchk}{}
27\registerctxluafile{grphcon}{}
28\registerctxluafile{grphfil}{}
29
30\registerctxluafile{grphu3d}{}
31
32
33\unprotect
34
35
36
37
38
39
40
41
42
43\ifdefined\dotagfigure \else \aliased\let\dotagfigure\relax \fi
44
45\installcorenamespace{externalfigure}
46\installcorenamespace{externalfigureinstance}
47\installcorenamespace{externalfigurecollection}
48
49\installframedcommandhandler \??externalfigure {externalfigure} \??externalfigure
50
51\aliased\let\setupexternalfigures\setupexternalfigure
52
53\setupexternalfigures[
54 \c!method =,
55 \c!label =,
56 \c!size =,
57 \c!conversion =,
58 \c!resolution =,
59 \c!prefix =,
60 \c!cache =,
61 \c!page =\zerocount,
62 \c!file =,
63 \c!display =,
64 \c!mask =,
65 \c!range =,
66 \c!preset =\v!yes,
67 \c!split =,
68 \c!color =,
69 \c!arguments =,
70 \c!symbol =\v!no,
71 \c!controls =\v!no,
72 \c!resources =,
73 \c!preview =\v!no,
74 \c!repeat =\v!no,
75 \c!foregroundcolor=,
76 \c!interaction =\v!none,
77 \c!hfactor =,
78 \c!wfactor =,
79 \c!factor =,
80 \c!defaultwidth =8\lineheight,
81 \c!defaultheight =6\lineheight,
82 \c!maxwidth =\externalfigureparameter\c!width,
83 \c!maxheight =\externalfigureparameter\c!height,
84 \c!xscale =,
85 \c!yscale =,
86 \c!scale =,
87 \c!sx =\externalfigureparameter\c!s,
88 \c!sy =\externalfigureparameter\c!s,
89 \c!s =1,
90 \c!width =,
91 \c!height =,
92 \c!lines =,
93 \c!grid =,
94 \c!bodyfont =\bodyfontsize,
95 \c!object =\v!yes,
96 \c!corner =\v!rectangular,
97 \c!frame =\v!off,
98 \c!option =,
99 \c!reset =\v!no,
100 \c!directory =,
101 \c!radius =.5\bodyfontsize,
102 \c!background =,
103 \c!splitcolor =\s!white,
104 \c!order =,
105 \c!equalwidth =,
106 \c!equalheight =,
107 \c!location ={\v!local,\v!global},
108 \c!frames =\v!off,
109 \c!ymax =24,
110 \c!xmax =,
111 \c!align =\v!none,
112 \c!crossreference =\v!no,
113 \c!transform =\v!auto,
114 \c!userpassword =,
115 \c!ownerpassword =,
116 \c!compact =,
117 \c!metadata =\v!page,
118 \c!cmyk =,
119 \c!crop =\v!yes,
120 ]
121
122
123
124\newinteger\c_grph_include_nesting
125
126\newtoks \everyexternalfigureresets
127\newtoks \everyexternalfigurechecks
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177\newconditional\c_grph_include_trace_inheritance
178
179\installtextracker
180 {graphics.inheritance}
181 {\c_grph_include_trace_inheritance\conditionaltrue}
182 {\c_grph_include_trace_inheritance\conditionalfalse}
183
184\installcorenamespace{externalfiguredefinition}
185
186\aliased\let\defineexternalfigures\defineexternalfigure
187
188
189
190
191
192\permanent\tolerant\protected\def\useexternalfigure[#1]#*[#2]#*[#S#3]#*[#S#4]
193 {\ifempty{#1}
194 \ifempty{#2}\else
195 \ifhastok={#3}
196 \grph_include_use_indeed{#2}{#2}{#3}{#4}
197 \else
198 \grph_include_use_indeed{#2}{#2}\empty{#4}
199 \fi
200 \fi
201 \orelse\ifempty{#2}
202 \ifhastok={#3}
203 \grph_include_use_indeed{#1}{#1}\empty{#3}
204 \else
205 \grph_include_use_indeed{#1}{#1}{#3}{#4}
206 \fi
207 \else
208 \ifhastok={#3}
209 \grph_include_use_indeed{#1}{#2}\empty{#3}
210 \else
211 \grph_include_use_indeed{#1}{#2}{#3}{#4}
212 \fi
213 \fi}
214
215\def\grph_include_use_indeed#1#2#3#4
216 {\gdefcsname\??externalfigureinstance#1\endcsname{\grph_include_setup{#2}{#3}{#4}}
217 \grph_include_analyze_collection[#2][#4]}
218
219
220
221\permanent\tolerant\protected\def\externalfigure[#1]#,[#2]#,[#S#3]
222 {\ifhastok={#2}
223 \grph_include_place[#1][][#2]
224 \else
225 \grph_include_place[#1][#2][#3]
226 \fi}
227
228
229
230\def\grph_include_setup#1#2#3
231 {\cdef\m_grph_include_name {#1}
232 \cdef\m_grph_include_parent{#2}
233 \ifempty\m_grph_include_name \else
234 \let\p_grph_include_name\m_grph_include_name
235 \fi
236 \ifempty\m_grph_include_parent \else
237 \grph_include_inherit_from_parent\m_grph_include_parent
238 \fi
239 \setupcurrentexternalfigure[#3]}
240
241\def\grph_include_inherit_from_parent#1
242 {\ifcsname\??externalfigure#1:\s!parent\endcsname
243 \let\currentexternalfigure#1
244 \fi
245 \ifcsname\??externalfigureinstance#1\endcsname
246 \ifconditional\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from instance: #1}\fi
247 \csname\??externalfigureinstance#1\endcsname
248 \fi}
249
250\newtoks\t_grph_include_local_settings
251
252\appendtoks
253 \enforced\let\textunderscore\letterunderscore
254
255 \dontcomplain
256 \restorecatcodes
257 \forgetall
258\to \t_grph_include_local_settings
259
260\def\grph_include_place_inherit
261 {\ifconditional\c_grph_include_trace_inheritance
262 \writestatus\m!figures{label: \p_grph_include_label, name: \p_grph_include_name, parent: \p_grph_include_parent}
263 \fi
264 \ifempty\p_grph_include_parent
265
266 \orelse\ifx\p_grph_include_parent\p_grph_include_label
267
268 \else
269 \grph_include_inherit_from_parent\p_grph_include_parent
270 \fi
271 \ifempty\p_grph_include_label
272
273 \else
274 \grph_include_inherit_from_parent\p_grph_include_label
275 \fi}
276
277\def\grph_include_place[#1][#S#2][#S#3]
278 {\bgroup
279 \advanceby\c_grph_include_nesting\plusone
280 \cdef\currentexternalfigure{\the\c_grph_include_nesting}
281 \checkexternalfigureparent
282
283 \expand\everyexternalfigureresets
284
285 \edef\p_grph_include_label{#1}
286 \let\p_grph_include_name\p_grph_include_label
287 \ifhastok={#2}
288
289 \let\p_grph_include_parent\p_grph_include_label
290 \grph_include_place_inherit
291 \setupcurrentexternalfigure[#2]
292 \else
293
294 \edef\p_grph_include_parent{#2}
295 \ifempty\p_grph_include_parent
296 \let\p_grph_include_parent\p_grph_include_label
297 \fi
298 \grph_include_place_inherit
299 \setupcurrentexternalfigure[#3]
300 \fi
301
302 \expand\everyexternalfigurechecks
303
304 \expand\t_grph_include_local_settings
305
306 \edef\p_width {\externalfigureparameter\c!width}
307 \edef\p_height {\externalfigureparameter\c!height}
308 \edef\p_label {\externalfigureparameter\c!label}
309 \edef\p_reference{\externalfigureparameter\c!reference}
310
311 \dostarttagged\t!image\empty
312 \clf_figure_push {
313 name {\p_grph_include_name}
314 label {\ifempty\p_label\p_grph_include_label\else\p_label\fi}
315 page {\externalfigureparameter\c!page}
316 file {\externalfigureparameter\c!file}
317 size {\externalfigureparameter\c!size}
318 object {\externalfigureparameter\c!object}
319 prefix {\externalfigureparameter\c!prefix}
320 cache {\externalfigureparameter\c!cache}
321 format {\externalfigureparameter\c!method}
322 preset {\externalfigureparameter\c!prefix}
323 controls {\externalfigureparameter\c!controls}
324 resources {\externalfigureparameter\c!resources}
325 preview {\externalfigureparameter\c!preview}
326 display {\externalfigureparameter\c!display}
327 mask {\externalfigureparameter\c!mask}
328 range {\externalfigureparameter\c!range}
329 conversion {\externalfigureparameter\c!conversion}
330 resolution {\externalfigureparameter\c!resolution}
331 color {\externalfigureparameter\c!color}
332 cmyk {\externalfigureparameter\c!cmyk}
333 arguments {\externalfigureparameter\c!arguments}
334 repeat {\externalfigureparameter\c!repeat}
335 transform {\externalfigureparameter\c!transform}
336 compact {\externalfigureparameter\c!compact}
337 metadata {\externalfigureparameter\c!metadata}
338 userpassword {\externalfigureparameter\c!userpassword}
339 ownerpassword{\externalfigureparameter\c!ownerpassword}
340 crop {\externalfigureparameter\c!crop}
341 \ifempty\p_width \else
342 width \dimexpr\p_width\relax
343 \fi
344 \ifempty\p_height \else
345 height \dimexpr\p_height\relax
346 \fi
347 }
348 \clf_figure_identify
349 \relax
350 \ifconditional\c_grph_include_test_only
351 \ifcase\figurestatus \else
352 \clf_figure_check
353 \clf_figure_dummy
354 \clf_figure_scale
355 \clf_figure_done
356 \fi
357 \grph_include_set_mode
358 \else
359 \ifcase\figurestatus
360 \clf_figure_dummy
361 \clf_figure_scale
362 \else
363 \clf_figure_check
364 \clf_figure_include
365 \clf_figure_scale
366 \fi
367 \clf_figure_done
368 \grph_include_set_mode
369 \grph_include_finalize
370 \fi
371 \clf_figure_pop
372 \dotagfigure
373
374 \scratchcounter\zerocount
375 \edef\p_crossreference{\externalfigureparameter\c!crossreference}
376 \iflocation\iftrialtypesetting\else
377 \ifempty\p_crossreference
378
379 \orelse\ifx\p_crossreference\v!no
380
381 \orelse\ifx\p_crossreference\v!yes
382 \ifhastok={#2}
383 \scratchcounter\clf_figure_register_page{#1}{}{#2}\relax
384 \else
385 \scratchcounter\clf_figure_register_page{#1}{#2}{#3}\relax
386 \fi
387 \else
388 \scratchcounter\p_crossreference
389 \fi
390 \fi\fi
391 \naturalvpack
392 attr \imageattribute \plustwo
393 \ifnum\scratchcounter>\zerocount
394 {\strc_references_cross_forward {ex:\number \scratchcounter}{\box\foundexternalfigure}}
395 \orelse\ifnum\scratchcounter<\zerocount
396 {\strc_references_cross_backward{ex:\number\scratchcounter}{\box\foundexternalfigure}}
397 \else
398 {\box\foundexternalfigure}
399 \fi
400
401
402
403
404
405
406
407
408
409
410
411 \dostoptagged
412 \egroup}
413
414\permanent\protected\def\setfigureconversion[#1]#*[#2]
415 {\clf_setfigureconversion{#1}{#2}}
416
417
418
419\def\strc_references_cross_forward#1#2
420 {\begingroup
421 \strc_references_set_simple_internal_reference{cross:b:#1}
422 \naturalhpack
423 attr \destinationattribute\number\lastdestinationattribute
424 {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:f:#1]}}
425 \endgroup}
426
427\def\strc_references_cross_backward#1#2
428 {\begingroup
429 \strc_references_set_simple_internal_reference{cross:f:#1}
430 \naturalhpack
431 attr \destinationattribute\number\lastdestinationattribute
432 {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:b:#1]}}
433 \endgroup}
434
435\aliased\let\doexternalfigurerepeat\gobblefourarguments
436
437\permanent\tolerant\protected\def\placeregisteredexternalfigures[#1]
438 {\page
439 \begingroup
440 \enforced\protected\def\doexternalfigurerepeat{\grph_include_place_registered_indeed{#1}}
441 \dorecurse\clf_figure_nof_registered_pages
442 {\page
443 \clf_figure_flush_registered_pages\recurselevel
444 \page}
445 \endgroup
446 \page}
447
448\protected\def\grph_include_place_registered_indeed#1#2#3#4#5
449 {\grph_include_place[#2][#3][#4,
450 \c!hfactor=,\c!wfactor=,\c!factor=,
451 \c!maxwidth=,\c!maxheight=,
452 \c!xscale=,\c!yscale=,\c!scale=,
453 \c!sx=,\c!sy=,\c!s=,
454 \c!width=,\c!height=,
455 \c!crossreference=#5,
456 #1]}
457
458
459
460\mutable\let\dowithfigure\relax
461
462\permanent\protected\def\doscalefigure
463 {\global\setbox\foundexternalfigure\vpack{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
464
465\definescale
466 [\v!figure]
467 [\c!hfactor =\externalfigureparameter\c!hfactor,
468 \c!wfactor =\externalfigureparameter\c!wfactor,
469 \c!factor =\externalfigureparameter\c!factor,
470 \c!maxwidth =\externalfigureparameter\c!maxwidth,
471 \c!maxheight =\externalfigureparameter\c!maxheight,
472 \c!equalwidth =\externalfigureparameter\c!equalwidth,
473 \c!equalheight=\externalfigureparameter\c!equalheight,
474 \c!xscale =\externalfigureparameter\c!xscale,
475 \c!yscale =\externalfigureparameter\c!yscale,
476 \c!scale =\externalfigureparameter\c!scale,
477 \c!sx =\externalfigureparameter\c!sx,
478 \c!sy =\externalfigureparameter\c!sy,
479 \c!s =\externalfigureparameter\c!s,
480 \c!width =\externalfigureparameter\c!width,
481 \c!height =\externalfigureparameter\c!height,
482 \c!lines =\externalfigureparameter\c!lines]
483
484
485
486
487
488
489
490
491
492\permanent\tolerant\protected\def\definegraphictypesynonym[#1]#*[#2]
493 {\clf_registerfiguresuffix{#1}{#2}}
494
495
496
497
498\permanent\protected\def\setfigurepathlist
499 {\clf_setfigurepaths{\externalfigureparameter\c!location}{\externalfigureparameter\c!directory}}
500
501
502
503\newbox \foundexternalfigure
504\newtoks\externalfigurepostprocessors
505
506\permanent\def\figurestatus {\numexpr\clf_figurestatus{status}{0}\relax}
507\permanent\def\figurewidth {\clf_figurestatus{width}{0}sp}
508\permanent\def\figureheight {\clf_figurestatus{height}{0}sp}
509\permanent\def\figurexscale {\clf_figurestatus{xscale}{1}}
510\permanent\def\figureyscale {\clf_figurestatus{yscale}{1}}
511\permanent\def\figurereference {\clf_figurestatus{reference}{}}
512
513\permanent\def\figuresize {\clf_figurerequest{size}{}}
514\permanent\def\figurelabel {\clf_figurerequest{label}{}}
515\permanent\def\figurefileoriginal {\clf_figurerequest{name}{}}
516\permanent\def\figurefilepage {\clf_figurerequest{page}{1}}
517\permanent\def\figurefileoptions {\clf_figurerequest{options}{}}
518\permanent\def\figurefileconversion{\clf_figurerequest{conversion}{}}
519\permanent\def\figurefileresolution{\clf_figurerequest{resolution}{}}
520\permanent\def\figurefilecolor {\clf_figurerequest{color}{}}
521\permanent\def\figurefilearguments {\clf_figurerequest{arguments}{}}
522\permanent\def\figurefilecache {\clf_figurerequest{cache}{}}
523\permanent\def\figurefileprefix {\clf_figurerequest{prefix}{}}
524
525\permanent\def\figurenaturalwidth {\clf_figureused{width}{\number\dimexpr\externalfigureparameter\c!defaultwidth\relax}sp}
526\permanent\def\figurenaturalheight {\clf_figureused{height}{\number\dimexpr\externalfigureparameter\c!defaultheight\relax}sp}
527\permanent\def\figurexresolution {\clf_figureused{xresolution}{0}}
528\permanent\def\figureyresolution {\clf_figureused{yresolution}{0}}
529\permanent\def\figureorientation {\clf_figureused{orientation}{1}}
530\permanent\def\figurerotation {\clf_figureused{rotation}{0}}
531\permanent\def\figurexsize {\clf_figureused{xsize}{0}}
532\permanent\def\figureysize {\clf_figureused{ysize}{0}}
533\permanent\def\figurecolordepth {\clf_figureused{colordepth}{0}}
534\permanent\def\figuredepth {\clf_figureused{depth}{0}}
535
536\permanent\def\figurefullname {\clf_figureused{fullname}{}}
537\permanent\def\noffigurepages {\clf_figureused{pages}{0}}
538
539
540
541
542
543
544\permanent\let\naturalfigurewidth \figurenaturalwidth
545\permanent\let\naturalfigureheight \figurenaturalheight
546
547\aliased\let\figurescalewidth \figurewidth
548\aliased\let\figurescaleheight \figureheight
549\aliased\let\figurescalexscale \figurexscale
550\aliased\let\figurescaleyscale \figureyscale
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566\newconditional\c_grph_include_skip
567\newconditional\c_grph_include_test_only
568\newconditional\c_grph_include_level \c_grph_include_level\conditionalfalse
569\newconditional\c_grph_include_flush \c_grph_include_flush\conditionaltrue
570
571\newsystemmode\v!figure
572
573\def\grph_include_set_mode
574 {\ifcase\figurestatus
575 \globalresetsystemmode\v!figure
576 \else
577 \globalsetsystemmode \v!figure
578 \fi}
579
580\appendtoks
581 \clf_setfigurepaths
582 {\externalfigureparameter\c!location}
583 {\externalfigureparameter\c!directory}
584 \clf_figure_reset
585 \foundexternalfigure
586 \externalfigureparameter\c!defaultwidth
587 \externalfigureparameter\c!defaultheight
588 \relax
589\to \everyexternalfigureresets
590
591\appendtoks
592 \edef\p_option{\externalfigureparameter\c!option}
593 \ifx\p_option\v!frame
594 \c_grph_include_skip\conditionalfalse
595 \letexternalfigureparameter\c!frame\v!on
596 \orelse\ifx\p_option\v!empty
597 \c_grph_include_skip\conditionaltrue
598 \letexternalfigureparameter\c!frame\v!off
599 \else
600 \c_grph_include_skip\conditionalfalse
601 \fi
602
603
604 \edef\p_foregroundcolor{\externalfigureparameter\c!foregroundcolor}
605 \ifempty\p_foregroundcolor \else
606 \setexternalfigureparameter\c!background{\v!foreground,\v!color}
607 \letexternalfigureparameter\c!backgroundcolor\p_foregroundcolor
608 \fi
609\to \everyexternalfigurechecks
610
611
612
613
614
615
616\def\grph_include_process_tex#1
617 {\framed
618 [\c!strut=\v!none,\c!align=\v!normal,\c!frame=\v!off,
619 \c!offset=\v!overlay,\c!width=\v!fit,\c!height=\v!fit]
620 {\blank[\v!disable]
621 #1\endgraf
622 \removelastskip}}
623
624
625
626
627\permanent\protected\def\docheckfigurebuffer #1{\global\setbox\foundexternalfigure\vpack{\grph_include_process_tex{\getbuffer[#1]}}}
628\permanent\protected\def\docheckfiguretex #1{\global\setbox\foundexternalfigure\vpack{\grph_include_process_tex{\input{#1}}}}
629\permanent\protected\def\docheckfigurecld #1{\global\setbox\foundexternalfigure\vbox {\cldprocessfile{#1}}}
630\permanent\protected\def\docheckfiguremps #1{\global\setbox\foundexternalfigure\vpack{\convertMPtoPDF{#1}11}}
631\permanent\protected\def\docheckfiguremprun #1#2{\global\setbox\foundexternalfigure\vpack{\useMPrun{#1}{#2}}}
632
633\permanent\protected\def\relocateexternalfigure
634 {\global\setbox\foundexternalfigure\vpack to \ht\foundexternalfigure\bgroup
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653 \vkern\ht\foundexternalfigure
654
655 \ht\foundexternalfigure\zeropoint
656 \dp\foundexternalfigure\zeropoint
657 \hpack to \wd\foundexternalfigure\bgroup
658 \box\foundexternalfigure
659 \hss
660 \egroup
661 \egroup}
662
663\permanent\protected\def\startfoundexternalfigure#1#2
664 {\global\setbox\foundexternalfigure\vbox to #2\bgroup\vss\hbox to #1\bgroup}
665
666\permanent\protected\def\stopfoundexternalfigure
667 {\hss\egroup\egroup}
668
669\permanent\protected\def\emptyfoundexternalfigure
670 {\startfoundexternalfigure{\externalfigureparameter\c!defaultwidth}{\externalfigureparameter\c!defaultheight}
671 \stopfoundexternalfigure}
672
673
674
675
676
677\def\grph_include_finalize
678 {\global\setbox\foundexternalfigure\vbox
679 {\ifcase\figurestatus
680 \letexternalfigureparameter\c!frame\v!on
681 \fi
682 \ifconditional\c_grph_include_flush
683 \ifconditional\c_grph_include_level
684 \ifconditional\c_grph_include_skip
685
686 \fakebox\foundexternalfigure
687 \orelse\ifcase\figurestatus
688
689 \else
690 \expand\externalfigurepostprocessors
691 \box\foundexternalfigure
692 \fi
693 \else
694 \iftrialtypesetting \else \feedbackexternalfigure \fi
695 \c_grph_include_level\conditionaltrue
696 \ifconditional\c_grph_include_skip
697 \ifcase\figurestatus
698 \grph_include_replacement\figurelabel\figurefileoriginal{unknown}
699 \else
700 \grph_include_replacement\figurelabel\figurefullname{skipped}
701 \fi
702 \orelse\ifcase\figurestatus
703 \grph_include_replacement\figurelabel\figurefileoriginal{unknown}
704 \else
705 \expand\externalfigurepostprocessors
706 \edef\p_reset{\externalfigureparameter\c!reset}
707 \ifx\p_reset\v!yes
708 \wd\foundexternalfigure\figurewidth
709 \ht\foundexternalfigure\figureheight
710 \dp\foundexternalfigure\zeropoint
711 \box\foundexternalfigure
712 \else
713 \letexternalfigureparameter\c!offset\v!overlay
714 \letexternalfigureparameter\c!width \figurewidth
715 \letexternalfigureparameter\c!height\figureheight
716 \inheritedexternalfigureframed{\box\foundexternalfigure}
717 \fi
718 \fi
719 \fi
720 \else
721
722 \iftrialtypesetting \else \feedbackexternalfigure \fi
723 \fi}}
724
725\mutable\let\feedbackexternalfigure\relax
726
727\permanent\tolerant\protected\def\getfiguredimensions[#1]#*[#S#2]
728 {\startnointerference
729 \c_grph_include_test_only\conditionaltrue
730 \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]
731 \stopnointerference}
732
733\permanent\protected\def\doifelsefigure#1
734 {\getfiguredimensions[#1]
735 \ifcase\figurestatus
736 \expandafter\secondoftwoarguments
737 \else
738 \expandafter\firstoftwoarguments
739 \fi}
740
741\aliased\let\doiffigureelse\doifelsefigure
742
743
744
745\permanent\tolerant\protected\def\registerexternalfigure[#1]#*[#S#2]#*[#S#3]
746 {\startnointerference
747 \c_grph_include_test_only
748 \c_grph_include_flush\conditionalfalse
749 \externalfigure[#1][#2][#3]
750 \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]
751 \stopnointerference}
752
753
754
755
756\permanent\protected\def\dosetfigureobject#1#2
757 {\setobject{#1}{#2}\vpack{\box\foundexternalfigure}}
758
759\permanent\protected\def\doboxfigureobject#1#2
760 {\global\setbox\foundexternalfigure\vpack{\getobject{#1}{#2}}}
761
762
763
764\permanent\protected\def\usefigurebase[#1]
765 {\clf_usefigurebase{#1}}
766
767\appendtoks
768 \setfigurepathlist
769\to \everysetupexternalfigure
770
771\appendtoks
772 \clf_setfigurelookuporder{\externalfigureparameter\c!order}
773\to \everysetupexternalfigure
774
775\definecolor[missingfigurecolor][s=.8]
776
777\def\grph_include_replacement#1#2#3
778 {\bgroup
779 \letexternalfigureparameter\c!width\figurewidth
780 \letexternalfigureparameter\c!height\figureheight
781 \letexternalfigureparameter\c!background\v!color
782 \setexternalfigureparameter\c!backgroundcolor{missingfigurecolor}
783 \setexternalfigureparameter\c!align{\v!middle,\v!lohi}
784 \inheritedexternalfigureframed
785 {\ttxx \nohyphens
786
787
788 name: \expandeddetokenize{#1}\crlf
789 file: \expandeddetokenize{#2}\crlf
790 state: #3
791 }
792 \egroup}
793
794
795
796\newconditional\c_grph_include_in_collection
797
798\newdimension \d_grph_include_collection_minwidth
799\newdimension \d_grph_include_collection_maxwidth
800\newdimension \d_grph_include_collection_minheight
801\newdimension \d_grph_include_collection_maxheight
802
803\def\grph_include_analyze_collection[#1][#S#2]
804 {\ifconditional\c_grph_include_in_collection
805 \c_grph_include_in_collection\conditionalfalse
806 \getfiguredimensions[#1][#2]
807 \c_grph_include_in_collection\conditionaltrue
808 \scratchdimen\naturalfigurewidth
809 \ifdim\scratchdimen>\d_grph_include_collection_maxwidth \d_grph_include_collection_maxwidth \scratchdimen \fi
810 \ifdim\scratchdimen<\d_grph_include_collection_minwidth \d_grph_include_collection_minwidth \scratchdimen \fi
811 \scratchdimen\naturalfigureheight
812 \ifdim\scratchdimen>\d_grph_include_collection_maxheight \d_grph_include_collection_maxheight\scratchdimen \fi
813 \ifdim\scratchdimen<\d_grph_include_collection_minheight \d_grph_include_collection_minheight\scratchdimen \fi
814 \fi}
815
816\mutable\lettonothing\currentexternalfigurecollection
817
818\permanent\protected\def\startexternalfigurecollection[#1]
819 {\begingroup
820 \cdef\currentexternalfigurecollection{#1}
821 \c_grph_include_in_collection\conditionaltrue
822 \d_grph_include_collection_minwidth \maxdimen
823 \d_grph_include_collection_maxwidth \zeropoint
824 \d_grph_include_collection_minheight\maxdimen
825 \d_grph_include_collection_maxheight\zeropoint}
826
827\permanent\protected\def\stopexternalfigurecollection
828 {\xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!minwidth \endcsname{\the\d_grph_include_collection_minwidth }
829 \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!maxwidth \endcsname{\the\d_grph_include_collection_maxwidth }
830 \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!minheight\endcsname{\the\d_grph_include_collection_minheight}
831 \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!maxheight\endcsname{\the\d_grph_include_collection_maxheight}
832 \endgroup}
833
834\permanent\def\externalfigurecollectionparameter#1#2
835 {\csname
836 \ifcsname\??externalfigurecollection#1:#2\endcsname
837 \??externalfigurecollection#1:#2
838 \else
839 \s!empty
840 \fi
841 \endcsname}
842
843\permanent\def\externalfigurecollectionminwidth #1{\externalfigurecollectionparameter{#1}\c!minwidth }
844\permanent\def\externalfigurecollectionmaxwidth #1{\externalfigurecollectionparameter{#1}\c!maxwidth }
845\permanent\def\externalfigurecollectionminheight#1{\externalfigurecollectionparameter{#1}\c!minheight}
846\permanent\def\externalfigurecollectionmaxheight#1{\externalfigurecollectionparameter{#1}\c!maxheight}
847
848\aliased\let\efcparameter\externalfigurecollectionparameter
849\aliased\let\efcminwidth \externalfigurecollectionminwidth
850\aliased\let\efcmaxwidth \externalfigurecollectionmaxwidth
851\aliased\let\efcminheight\externalfigurecollectionminheight
852\aliased\let\efcmaxheight\externalfigurecollectionmaxheight
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867\permanent\protected\def\overlayfigure#1
868 {\externalfigure[#1][\c!width=\d_overlay_width,\c!height=\d_overlay_height]}
869
870
871
872\permanent\tolerant\protected\def\includesvgfile[#1]#*[#S#2]
873 {\hbox\bgroup
874 \getdummyparameters[\c!offset=\zeropoint,#2]
875 \clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax
876 \egroup}
877
878\permanent\tolerant\protected\def\includesvgbuffer[#1]#*[#S#2]
879 {\hbox\bgroup
880 \getdummyparameters[\c!offset=\zeropoint,#2]
881 \clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax
882 \egroup}
883
884
885
886\useexternalfigure
887 [\v!buffer]
888 [\jobname.buffer]
889 [\c!object=\v!no]
890
891
892
893\defineexternalfigure
894 [\v!inline]
895 [\c!height=\lineheight]
896
897\permanent\protected\def\combinationwidth
898 {\dimexpr
899 (\textwidth
900 \effectiveleftskip
901 \effectiverightskip
902 \numexpr\combinationparameter\c!nx\plusone\relax\dimexpr\combinationparameter\c!distance\relax
903 )\combinationparameter\c!nx
904 \relax}
905
906\pushoverloadmode
907 \newuserunit \combinationwidth cx
908\popoverloadmode
909
910\definemeasure
911 [\v!combination]
912 [\combinationwidth]
913
914\defineexternalfigure
915 [\v!combination]
916 [\c!width=\combinationwidth]
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948\permanent\protected\def\inlinefigure[#1]
949 {\dontleavehmode
950 \sbox{\externalfigure[#1][\v!inline]}}
951
952
953
954\definelayer[epdfcontent]
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975\protect \endinput
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117 |