From 4f053696e1813fde4bd6cebbb77ff2a1e1f6800b Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg@phi-gamma.net>
Date: Thu, 29 Oct 2015 07:14:40 +0100
Subject: [fontloader] sync with Context as of 2015-10-29

---
 src/fontloader/misc/fontloader-mplib.tex | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

(limited to 'src/fontloader/misc/fontloader-mplib.tex')

diff --git a/src/fontloader/misc/fontloader-mplib.tex b/src/fontloader/misc/fontloader-mplib.tex
index 09dd179..f9de4b2 100644
--- a/src/fontloader/misc/fontloader-mplib.tex
+++ b/src/fontloader/misc/fontloader-mplib.tex
@@ -106,15 +106,14 @@
 
 %D Text items have a special handler:
 
-\def\MPLIBtextext#1#2#3#4#5%
+\def\MPLIBtextext#1#2#3#4%
   {\begingroup
    \setbox\mplibscratchbox\hbox
      {\font\temp=#1 at #2bp%
       \temp
       #3}%
    \setbox\mplibscratchbox\hbox
-     {\hskip#4 bp%
-      \raise#5 bp%
+     {\raise#4sp%
       \box\mplibscratchbox}%
    \wd\mplibscratchbox0pt%
    \ht\mplibscratchbox0pt%
@@ -122,4 +121,20 @@
    \box\mplibscratchbox
    \endgroup}
 
+\def\MPLIBpdftext#1#2%
+  {\ifcsname mplib::#1\endcsname
+     % already done, forgotten outside convert group
+     \message{<reusing mplib: #1>}%
+   \else
+     \message{<embedding mplib: #1>}%
+     \immediate\pdfximage{#1}% we cannot remove the file as it is included last
+     \expandafter\edef\csname mplib::#1\endcsname{\the\pdflastximage}%
+   \fi
+   \setbox\mplibscratchbox\hbox
+     {\raise#2sp\hbox{\pdfrefximage\csname mplib::#1\endcsname}}%
+   \wd\mplibscratchbox0pt%
+   \ht\mplibscratchbox0pt%
+   \dp\mplibscratchbox0pt%
+   \box\mplibscratchbox}
+
 \endinput
-- 
cgit v1.2.3

