[metapost] No log neither heigh of the fig (mplib)

Taco Hoekwater taco at elvenkind.com
Mon Jul 8 12:09:38 CEST 2019



> On 8 Jul 2019, at 11:41, Maxime Chupin <notezik at gmail.com> wrote:
> 
> Hi,
> I do not understand why the following code does not produce a log and a height (or width) for the fig. Any help to find out what I do not do right?

The height(), depth(), width() and italcorr() methods return the value you have set for charht, chardp, charwd, charit in metapost. Since you do not set any of those, the functions return 0.0. 

Either use the boundingbox() method which returns four floats for the boundingbox corners, or set charwd etc. from within metapost code.

Best wishes,
Taco

> 
> Thanks in advance
> 
> Maxime Chupin
> 
> local mpkpse = kpse.new('luatex', 'mpost')
> 
> local function finder(name, mode, ftype)
>    if mode == "w" then
>   return name
>    else
>   return mpkpse:find_file(name,ftype)
>    end
> end
> 
> 
> function getpathfrommp(s)
>    local mp = mplib.new({
>          find_file = finder,})
>    mp:execute('input plain ;')
>    local rettable
>    rettable = mp:execute('beginfig(1); draw (0,0)--(2cm,2cm); endfig;')
>    print("\nstatus: ".. rettable.status)
>    print(rettable.log)
>    if rettable.status == 0 then
>       print("height: "..rettable.fig[1]:height())
>    end
> end
> 
> getpathfrommp()
> 
> 
> -- 
> Maxime Chupin
> Site personnel : http://fougeriens.org/~mc/
> Site professionnel : https://www.ceremade.dauphine.fr/~chupin/
> adresse libre : chupin at fougeriens.org
> --
> http://tug.org/metapost/

Taco Hoekwater
Elvenkind BV







More information about the metapost mailing list