1
2
3
4
5
6
7
8
9
10
11
12
13
14\unprotect
15
16
17
18\registerctxluafile{mlibpdf}{autosuffix}
19
20
21
22
23\newdimension\MPwidth
24\newdimension\MPheight
25
26\newdimension\MPllx
27\newdimension\MPlly
28\newdimension\MPurx
29\newdimension\MPury
30
31\ifdefined\MPbox\else \newbox\MPbox\fi
32
33\permanent\protected\def\setMPboundingbox#1#2#3#4
34 {\global\MPllx #1\onebasepoint
35 \global\MPlly #2\onebasepoint
36 \global\MPurx #3\onebasepoint
37 \global\MPury #4\onebasepoint
38 \global\MPwidth \dimexpr\MPurx\MPllx\relax
39 \global\MPheight\dimexpr\MPury\MPlly\relax}
40
41\permanent\protected\def\resetMPboundingbox
42 {\global\MPwidth \zeropoint
43 \global\MPheight\zeropoint
44 \global\MPllx \zeropoint
45 \global\MPlly \zeropoint
46 \global\MPurx \zeropoint
47 \global\MPury \zeropoint}
48
49\permanent\protected\lettonothing\popMPboundingbox
50
51\permanent\protected\def\pushMPboundingbox
52 {\enforced\permanent\protected\edef\popMPboundingbox
53 {\global\MPwidth \the\MPwidth
54 \global\MPheight\the\MPheight
55 \global\MPllx \the\MPllx
56 \global\MPlly \the\MPlly
57 \global\MPurx \the\MPurx
58 \global\MPury \the\MPury
59 \relax}}
60
61
62
63\permanent\protected\def\repositionMPboxindeed
64 {\setbox\MPbox\hpack\bgroup
65 \kern\MPllx
66 \raise\MPlly
67 \box\MPbox
68 \egroup}
69
70\permanent\protected\def\repositionMPbox
71 {\ifzeropt\MPllx
72 \ifzeropt\MPlly
73
74 \else
75 \repositionMPboxindeed
76 \fi
77 \else
78 \repositionMPboxindeed
79 \fi}
80
81
82
83\permanent\protected\def\finalizeMPbox
84 {\boxxoffset\MPbox\MPllx\relax
85 \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox\MPheight\MPlly\relax
86 \wd\MPbox\MPwidth
87 \ht\MPbox\MPheight}
88
89
90
91
92
93
94
95
96
97
98
99
100
101\permanent\protected\def\startMPLIBtoPDF#1#2#3#4
102 {\meta_process_graphic_figure_start
103 \dostarttagged\t!mpgraphic\empty
104 \naturalhpack attr \imageattribute \plusone \bgroup
105 \dousecolorparameter\s!black
106 \setMPboundingbox{#1}{#2}{#3}{#4}
107 \setbox\MPbox\vpack\bgroup
108 \noindent}
109
110\permanent\protected\def\stopMPLIBtoPDF
111 {\egroup
112 \finalizeMPbox
113 \box\MPbox
114 \egroup
115 \dostoptagged
116 \meta_process_graphic_figure_stop}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132\aliased\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
133\aliased\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
134
135\permanent\protected\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
136\permanent\protected\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
137
138
139
140\permanent\protected\def\directMPgraphic
141 {\dodoublegroupempty\mlib_direct_graphic}
142
143\def\mlib_direct_graphic#1#2
144 {\meta_begin_graphic_group{#1}
145 \enforced\let\startMPLIBtoPDF\directstartMPLIBtoPDF
146 \enforced\let\stopMPLIBtoPDF \directstopMPLIBtoPDF
147 \meta_start_current_graphic
148 \forgetall
149 \edef\p_extensions{\MPinstanceparameter\s!extensions}
150 \normalexpanded{\noexpand\clf_mpgraphic
151 instance {\currentMPinstance}
152 format {\currentMPformat}
153 data {#2;}
154 initializations {\meta_flush_current_initializations}
155 \ifx\p_extensions\v!yes
156 extensions {\clf_getmpextensions{\currentMPinstance}}
157 \fi
158 inclusions {\meta_flush_current_inclusions}
159 definitions {\meta_flush_current_definitions}
160 figure {all}
161 method {\MPinstanceparameter\c!method}
162 \relax}
163 \meta_stop_current_graphic
164 \meta_end_graphic_group}
165
166\protect \endinput
167 |