1
2
3
4
5
6
7
8
9
10
11
12
13
14\unprotect
15
16
17
18\registerctxluafile{mlibpdf}{}
19
20
21
22
23\ifdefined\MPwidth \else \newdimen\MPwidth \fi
24\ifdefined\MPheight \else \newdimen\MPheight \fi
25
26\ifdefined\MPllx \else \newdimen\MPllx \fi
27\ifdefined\MPlly \else \newdimen\MPlly \fi
28\ifdefined\MPurx \else \newdimen\MPurx \fi
29\ifdefined\MPury \else \newdimen\MPury \fi
30
31\ifdefined\MPbox \else \newbox \MPbox \fi
32
33\unexpanded\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\unexpanded\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\let\popMPboundingbox\relax
50
51\unexpanded\def\pushMPboundingbox
52 {\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\unexpanded\def\repositionMPboxindeed
62 {\setbox\MPbox\hpack\bgroup
63 \kern\MPllx
64 \raise\MPlly
65 \box\MPbox
66 \egroup}
67
68\unexpanded\def\repositionMPbox
69 {\ifzeropt\MPllx
70 \ifzeropt\MPlly
71
72 \else
73 \repositionMPboxindeed
74 \fi
75 \else
76 \repositionMPboxindeed
77 \fi}
78
79\unexpanded\def\finalizeMPbox
80 {\repositionMPbox
81 \setbox\MPbox\vpack to \MPheight\bgroup
82 \vfill
83 \hsize\MPwidth
84 \smashbox\MPbox
85 \box\MPbox
86 \egroup
87 \wd\MPbox\MPwidth
88 \ht\MPbox\MPheight}
89
90
91
92\def\MPLIBtoPDF{\clf_mpflushliteral}
93
94\unexpanded\def\startMPLIBtoPDF#1#2#3#4
95 {\meta_process_graphic_figure_start
96 \dostarttagged\t!mpgraphic\empty
97 \naturalhpack attr \imageattribute \plusone \bgroup
98 \dousecolorparameter\s!black\forcecolorhack
99 \setMPboundingbox{#1}{#2}{#3}{#4}
100 \setbox\MPbox\vpack\bgroup
101
102 \noindent}
103
104\unexpanded\def\stopMPLIBtoPDF
105 {\egroup
106 \finalizeMPbox
107 \box\MPbox
108 \egroup
109 \dostoptagged
110 \meta_process_graphic_figure_stop}
111
112\def\MPLIBflushreset
113 {\clf_mpflushreset}
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
130\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
131
132\unexpanded\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
133\unexpanded\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
134
135\unexpanded\def\directMPgraphic
136 {\dodoublegroupempty\mlib_direct_graphic}
137
138\def\mlib_direct_graphic#1#2
139 {\meta_begin_graphic_group{#1}
140 \let\startMPLIBtoPDF\directstartMPLIBtoPDF
141 \let\stopMPLIBtoPDF \directstopMPLIBtoPDF
142 \meta_start_current_graphic
143 \forgetall
144 \edef\p_extensions{\MPinstanceparameter\s!extensions}
145 \normalexpanded{\noexpand\clf_mpgraphic
146 instance {\currentMPinstance}
147 format {\currentMPformat}
148 data {#2;}
149 initializations {\meta_flush_current_initializations}
150 \ifx\p_extensions\v!yes
151 extensions {\clf_getmpextensions{\currentMPinstance}}
152 \fi
153 inclusions {\meta_flush_current_inclusions}
154 definitions {\meta_flush_current_definitions}
155 figure {all}
156 method {\MPinstanceparameter\c!method}
157 \relax}
158 \meta_stop_current_graphic
159 \meta_end_graphic_group}
160
161\protect \endinput
162 |