summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mlib-pps.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/mlib-pps.mkiv97
1 files changed, 62 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/context/base/mlib-pps.mkiv b/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
index f21d84e0dbd..207d9730c8a 100644
--- a/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
+++ b/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
@@ -33,54 +33,88 @@
\newbox \MPtextbox
\newtoks\everyMPLIBsettext % not used
-\newconditional\MPLIBtextgetdone
-
% \def\MPLIBsettext#1% #2%
% {\dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
+%
+% \def\MPLIBresettexts
+% {\ctxlua{metapost.resettextexts()}}
+%
+% \newconditional\MPLIBtextgetdone
+%
+% \def\MPLIBsettext#1% #2%
+% {\ifconditional\MPLIBtextgetdone
+% \else
+% \cldcontext{metapost.tex.get()}% MPenvironments are depricated
+% \settrue\MPLIBtextgetdone % no \global needed
+% \fi
+% \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
+%
+% \def\MPLIBresettexts
+% {\ctxlua{metapost.resettextexts()}%
+% \setfalse\MPLIBtextgetdone}
-\def\MPLIBsettext#1% #2%
- {\ifconditional\MPLIBtextgetdone
- \else
- \cldcontext{metapost.tex.get()}% MPenvironments are depricated
- \settrue\MPLIBtextgetdone % no \global needed
- \fi
- \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
+\def\doMPLIBflushenvironment
+ {%\writestatus\m!metapost{flushing environment}%
+ \cldcontext{metapost.tex.get()}%
+ \let\MPLIBflushenvironment\relax}% MPenvironments are depricated}
-\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
+\let\MPLIBflushenvironment\doMPLIBflushenvironment
+
+\unexpanded\def\MPLIBsetNtext#1% #2% box text
+ {\MPLIBflushenvironment
+ \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox\bgroup
+ \meta_set_current_color
+ \let\MPLIBflushenvironment\doMPLIBflushenvironment
+ \let\next} % gobble open brace
+
+\unexpanded\def\MPLIBsetCtext#1#2% #3% box colorspec text
+ {\MPLIBflushenvironment
+ \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox\bgroup
+ \directcolored[#2]%
+ \meta_set_current_color % so, textcolor wins !
+ \let\MPLIBflushenvironment\doMPLIBflushenvironment
+ \let\next} % gobble open brace
+
+\let\MPLIBsettext\MPLIBsetNtext
+
+\unexpanded\def\MPLIBresettexts
+ {\ctxlua{metapost.resettextexts()}}
+
+\unexpanded\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
{\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=#2,\c!sy=#3]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}}
-\def\MPLIBfigure#1#2%
+\unexpanded\def\MPLIBfigure#1#2%
{\setbox\scratchbox\hbox{\externalfigure[#1][\c!mask=#2]}%
\ctxlua{metapost.edefsxsy(\number\wd\scratchbox,\number\ht\scratchbox,0)}%
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=\sx,\c!sy=\sy]{\box\scratchbox}\hss}}}
-% horrible:
+% horrible (we could inline scale and matrix code):
-\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
+\unexpanded\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
{\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
\setbox\MPbox\hbox\bgroup
\dotransformnextbox{#2}{#3}{#4}{#5}{#6}{#7}% does push pop ... will be changed to proper lua call (avoid small numbers)
\vbox to \zeropoint\bgroup
\vss
\hbox to \zeropoint \bgroup
-% \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}%
-% \scale[\c!sx=#8,\c!sy=#9,\c!depth=\v!no]{\box\MPtextbox}%
+ % \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}%
+ % \scale[\c!sx=#8,\c!sy=#9,\c!depth=\v!no]{\box\MPtextbox}%
\fastsxsy{#8}{#9}{\raise\dp\MPtextbox\box\MPtextbox}%
- % This gives: LuaTeX warning: Misplaced \pdfrestore .. don't ask me why.
- % but I'll retry it some day soon.
- % \dostartscaling{#8}{#9}%
- % \raise\dp\MPtextbox\box\MPtextbox
- % \dostopscaling
- \forcecolorhack % needed ? already in the scale macro
- \hss
+ % This gives: LuaTeX warning: Misplaced \pdfrestore .. don't ask me why.
+ % but I'll retry it some day soon.
+ % \dostartscaling{#8}{#9}%
+ % \raise\dp\MPtextbox\box\MPtextbox
+ % \dostopscaling
+ \forcecolorhack % can go away ... already in the scale macro
+ \hss
\egroup
\egroup
\egroup
\smashbox\MPbox
\box\MPbox}
-\def\MPLIBgraphictext#1% use at mp end
+\unexpanded\def\MPLIBgraphictext#1% use at mp end
{\startTEXpage[\c!scale=10000]#1\stopTEXpage}
%D \startbuffer
@@ -109,18 +143,11 @@
%D
%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection
-\def\MPLIBpositionwhd#1#2#3#4#5% bp !
+\unexpanded\def\MPLIBpositionwhd#1#2#3#4#5% bp !
{\dosavepositionwhd{#1}\zerocount{#2\onebasepoint}{#3\onebasepoint}{#4\onebasepoint}{#5\onebasepoint}\zeropoint}
-\def\MPLIBextrapass#1%
- {\ctxlua{metapost.graphic_extra_pass("#1")}}
-
-% \def\MPLIBresettexts
-% {\ctxlua{metapost.resettextexts()}}
-
-\def\MPLIBresettexts
- {\ctxlua{metapost.resettextexts()}%$
- \setfalse\MPLIBtextgetdone}
+% \def\MPLIBextrapass#1%
+% {\ctxlua{metapost.graphic_extra_pass("#1")}}
%D Experiment
@@ -142,9 +169,9 @@
\box\scratchbox
\endgroup}
-\def\MPLIBstartgroup#1#2#3#4#5#6% isolated 0/1, knockout 0/1 llx lly urx ury
+\unexpanded\def\MPLIBstartgroup#1#2#3#4#5#6% isolated 0/1, knockout 0/1 llx lly urx ury
{\begingroup
\setbox\scratchbox\hbox\bgroup
- \def\MPLIBstopgroup{\doMPLIBstopgroup{#1}{#2}{#3}{#4}{#5}{#6}}}
+ \unexpanded\def\MPLIBstopgroup{\doMPLIBstopgroup{#1}{#2}{#3}{#4}{#5}{#6}}}
\protect \endinput