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 {\MPurx\MPllx}
39 \global\MPheight{\MPury\MPlly}}
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{\boxyoffset\MPbox\MPheight\MPlly}
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#5
102 {\meta_process_graphic_figure_start
103 \dostarttaggednodetail\t!mpgraphic
104 \naturalhpack attr \imageattribute \plusone \bgroup
105 \ifnum#5=\plusone
106
107
108 \dousecolorparameter\s!black
109 \fi
110 \setMPboundingbox{#1}{#2}{#3}{#4}
111 \setbox\MPbox\vpack\bgroup
112 \noindent}
113
114\permanent\protected\def\stopMPLIBtoPDF
115 {\egroup
116 \finalizeMPbox
117 \box\MPbox
118 \egroup
119 \dostoptagged
120 \meta_process_graphic_figure_stop}
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136\aliased\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
137\aliased\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
138
139\permanent\protected\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
140\permanent\protected\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
141
142
143
144\permanent\protected\def\directMPgraphic
145 {\dodoublegroupempty\mlib_direct_graphic}
146
147\def\mlib_direct_graphic#1#2
148 {\meta_begin_graphic_group{#1}
149 \enforced\let\startMPLIBtoPDF\directstartMPLIBtoPDF
150 \enforced\let\stopMPLIBtoPDF \directstopMPLIBtoPDF
151 \meta_start_current_graphic
152 \forgetall
153 \edef\p_extensions{\MPinstanceparameter\s!extensions}
154 \normalexpanded{\noexpand\clf_mpgraphic
155 instance {\currentMPinstance}
156 format {\currentMPformat}
157 data {#2;}
158 initializations {\meta_flush_current_initializations}
159 \ifx\p_extensions\v!yes
160 extensions {\clf_getmpextensions{\currentMPinstance}}
161 \fi
162 inclusions {\meta_flush_current_inclusions}
163 definitions {\meta_flush_current_definitions}
164 figure {all}
165 method {\MPinstanceparameter\c!method}
166 \relax}
167 \meta_stop_current_graphic
168 \meta_end_graphic_group}
169
170\protect \endinput
171 |