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