summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/meta-pdf.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-pdf.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/meta-pdf.mkiv155
1 files changed, 155 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-pdf.mkiv b/Master/texmf-dist/tex/context/base/meta-pdf.mkiv
new file mode 100644
index 00000000000..eded7d59dbc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/meta-pdf.mkiv
@@ -0,0 +1,155 @@
+%D \module
+%D [ file=meta-pdf,
+%D version=2006.29.09,
+%D title=\CONTEXT\ Support Macros,
+%D subtitle=\METAPOST\ to \PDF\ conversion,
+%D author=Hans Hagen \& others (see text),
+%D date=\currentdate,
+%D copyright=\PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+% Using test case at end of meta-pdf.tex:
+%
+% \useMPgraphic{1}
+% \testfeatureonce{250}{\setbox0\hbox{\convertMPtoPDF{test-mps-mpgraph.1}{1}{1}}}
+%
+% 8.4 : mkii, direct parsing by tex
+% 11.8 : mkiv, dirty conversion (10.8 with dirty tricks)
+% 14.5 : mkiv, clean conversion
+% 7.4 : mkiv, simulated clean direct lua from mp
+% 0.3 : time taken by tex to handle converted code
+
+\registerctxluafile{meta-pdf}{1.003}
+
+%D Plugin.
+
+\def\mkconvertMPtoPDF % watch the transparency reset
+ {\vbox\bgroup
+ \forgetall
+ \offinterlineskip
+ %\ifcase\blackoutMPgraphic\or\PDFcode{0 g 0 G}\fi % fixed in mp
+ \setbox\scratchbox\vbox\bgroup
+ \setnormalcatcodes % we can be in verbatim or so
+ \message{[MP to PDF]}%
+ \startMPresources
+ \PDFcomment{mps begin}%
+ \PDFcode{q 1 0 0 1 0 0 cm}%
+ \ctxlua{mptopdf.convertmpstopdf("\MPfilename")}\removeunwantedspaces
+ \dohandleMPresettransparency % a bit messy here, should be a toks
+ \PDFcode{Q}%
+ \PDFcomment{mps end}%
+ \stopMPresources
+ \egroup
+ \setbox\scratchbox\hbox\bgroup
+ \hskip-\MPllx\onebasepoint
+ \raise-\MPlly\onebasepoint
+ \box\scratchbox
+ \egroup
+ \setbox\scratchbox\vbox to \MPheight\bgroup
+ \vfill
+ \hsize\MPwidth
+ \smashbox\scratchbox
+ \box\scratchbox
+ \egroup
+ \wd\scratchbox\MPwidth
+ \ht\scratchbox\MPheight
+ \dopackageMPgraphic\scratchbox
+ \egroup}
+
+\let\mkprocessMPtoPDFfile\mkconvertMPtoPDF
+
+% \def\TEXcode#1#2#3#4#5%
+% {\setbox\scratchbox\hbox
+% {\font\temp=#1\space at #2\onebasepoint
+% \temp
+% \MPfshowcommand{#3}}%
+% \setbox\scratchbox\hbox
+% {\hskip#4\onebasepoint
+% \raise#5\onebasepoint
+% \box\scratchbox}%
+% \smashbox\scratchbox
+% \box\scratchbox}
+
+% will be done better
+
+\def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can
+ {\def\MPtextdata{#3}% % delegate the splitter to lua + redesign
+ \def\MPtextsize{#2}%
+ \def\lastMPmoveX{#4}%
+ \def\lastMPmoveY{#5}%
+ \defconvertedcommand\MPtextdata\MPtextdata % no edef
+ \splitstring\MPtextdata\at::::\to\MPtexttag\and\MPtextnumber
+ \executeifdefined{handleMPtext\MPtexttag}
+ {\setbox\scratchbox\hbox
+ {\font\temp=#1\space at #2\onebasepoint
+ \let\c\char
+ \temp
+ \MPfshowcommand{#3}}%
+ \setbox\scratchbox\hbox
+ {\hskip#4\onebasepoint
+ \raise#5\onebasepoint
+ \box\scratchbox}%
+ \smashbox\scratchbox
+ \box\scratchbox}}
+
+%D We save the special variables on a stack. It's not that
+%D fast, but it make implementing the special more convenient.
+
+\def\MPSbegin
+ {\nofMParguments\zerocount}
+
+\def\MPSend
+ {\csname\MPspecial\endcsname}
+
+\def\MPSset
+ {\advance\nofMParguments\plusone
+ \expandafter\def\csname\@@MP\number\nofMParguments\endcsname}
+
+\def\gMPs#1{\csname\@@MP\number#1\endcsname}
+
+%D The boundingbox.
+
+\def\MPSboundingbox#1#2#3#4%
+ {\xdef\MPllx{#1}%
+ \xdef\MPlly{#2}%
+ \xdef\MPurx{#3}%
+ \xdef\MPury{#4}%
+ \xdef\MPwidth {\the\dimexpr#3\onebasepoint-#1\onebasepoint\relax}%
+ \xdef\MPheight{\the\dimexpr#4\onebasepoint-#2\onebasepoint\relax}}
+
+\MPSboundingbox0000
+
+\def\MPSspecial#1#2%
+ {\csname\@@MPSK#2\endcsname}
+
+%D A path is (in most cases) just a sequence of \PDF\ commands.
+
+% \newcontitional\ignoreMPpath
+
+\def\MPSpath
+ {\PDFcode}
+
+\def\MPScode % hack, will be improved
+ {\ifconditional\ignoreMPpath
+ \PDFcode{h W n}%
+ \ifx\extraMPpathcode\empty\else
+ \PDFcode{\extraMPpathcode}%
+ \let\extraMPpathcode\empty
+ \fi
+ \setfalse\ignoreMPpath
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\PDFcode
+ \fi}
+
+\let\MPSrgb \dohandleMPrgb
+\let\MPScmyk\dohandleMPcmyk
+\let\MPSgray\dohandleMPgray
+\let\MPSspot\dohandleMPspot
+
+\protect \endinput