[luatex] Problem with mplib format in Lua script

Taco Hoekwater taco at elvenkind.com
Sun Dec 20 18:15:05 CET 2009


Nicola wrote:
> mplib uses 1.207, I thought there was a format mismatch. 

Yes, there would have been.

> So, I've tried to generate a format file through mplib:
> 
> local mplib = require('mplib') 
> local mp = mplib.new ({ ini_version = true, mem_name = 'plain' })
> if mp then
>    mp:execute('dump;')
>    mp:finish();
> end
> This has generated plain.mem in the current directory (but it's only 
> ~13kb). 

That is because it only contains primitives. To do the mem generation
right, you need something like this:

   local mplib = require('mplib')
   local kpse  = require('kpse')

   local kpsedb = kpse.new('mpost')

   local function finder(name, mode, ftype)
     if mode=="w" then
         return name
     else
         return kpsedb:find_file(name,ftype)
     end
   end

   local mp = mplib.new ({ find_file = finder,
	  		  ini_version = true,
			  mem_name = 'plain'})
   if mp then
     mp:execute('input plain; dump;')
     mp:finish();
   end

The needed runtime is the same you had, except for 'find_file = finder'
that needs to be added to the call to mplib.new, as otherwise all your
files have to be in the local directory.

But keeping mem files up-to-date is a bit of a pain, especially for the
embedded version of the library, so I would suggest not using them at
all (plain.mp is tiny anyway).

Just set ini_version to true always and start with an

   mp:execute("input plain")

Best wishes,
Taco




More information about the luatex mailing list