[metapost] Using the mplib inside luatex

Taco Hoekwater taco at elvenkind.com
Mon Jan 5 13:34:18 CET 2009


Hi,

Yesterday Elie Roux emailed me asking how to use mplib because
my example from the tug2008 slides didn't actually work in real
life. Well, even if it would have worked as advertised, it would
still have been useless because all it does is print the postscript
representation of the first generated figure to the terminal.

Therefore, I decided to create a real demonstration by ripping
out some key bits of the ConTeXt mplib support. The files I
created are in the attached zip: one plain tex and one lua
file that work together to do inline mplib-based conversion.
Also in the zip is a small test file.

A whole bunch of caveats apply to the files in this zip:

* The only test case I ran is the example file, nothing more. The
   original code inside ConTeXt works just fine, but it is possible
   that I have broken something during the extraction process.
   (The ConTeXt code does much more than the attached code. For
    instance: it creates, caches, and auto-upgrades mem files;
    it allows multiple formats in a single document, and it offers
    a way to reset the mplib instance.)

* There is not much documentation in the files. I removed the
   context-specific comments on purpose to avoid confusion,
   and did not bother to insert new comments. The most helpful
   tool to understand what is going on is the lua api
   documentation in mplibapi.tex from the metapost distribution,
   or the mplib chapter in the luatex reference manual (both
   cover the same information)

* The code does not check the mplib version like it should.
   The reason for that is that the mplib lua interface may
   change (or be extended) in the future. The assumption the
   code makes is that mplib is 1.10x.

* The code assumes that you have created the mem files outside of
   luatex, which in turn means that mplib-in-luatex and standalone
   mpost should have the exact same version number. If this is not
   the case, then extra lua code has to be written to create .mem
   files specifically for mplib-in-luatex, and the resulting
   mem files should be stored in a location where mplib-in-luatex
   finds it before the 'normal' mem file.

* I have no interest in maintaining or extending this code at all.
   It would be nice if someone was willing to convert it into a
   latex or plain package and upload it to CTAN, but that person
   will definately not be me. I have too much on my plate already.
   Distribution and/or modification of the attached
   code is free and there is no warranty of any kind.

* I hope that is all. ;-)

Have fun,
Taco

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplib-plain.zip
Type: application/zip
Size: 5045 bytes
Desc: not available
Url : http://tug.org/pipermail/metapost/attachments/20090105/2b2b510b/attachment.zip 


More information about the metapost mailing list