Skip to content

class MpInstance

😱 Types incomplete or incorrect? πŸ™ Please contribute!


methods


MpInstance.statistics


function MpInstance.statistics() ->  MpStats {
    main_memory = integer,
    hash_size = integer,
    param_size = integer,
    max_in_open = integer,
}

Return some statistics for this metapost instance.

This function returns the vital statistics for an MPlib instance.

Note that in the new version of MPlib, this is informational only. The objects are all allocated dynamically, so there is no chance of running out of space unless the available system memory is exhausted.

Reference:

MpInstance.execute


function MpInstance.execute(code: string) ->  MpResult {
    log = string?,
    term = string?,
    error = string?,
    status = MpResultStatus,
    fig = MpFig[]?,
}

Execute metapost code in the instance.

You can ask the MetaPost interpreter to run a chunk of code by calling mp.execute()

for various bits of MetaPost language input. Be sure to check the rettable.status (see below) because when a fatal MetaPost error occurs the MPlib instance will become unusable thereafter.

Generally speaking, it is best to keep your chunks small, but beware that all chunks have to obey proper syntax, like each of them is a small file. For instance, you cannot split a single statement over multiple chunks.

In contrast with the normal stand alone mpost command, there is no implied β€œinput” at the start of the first chunk.

Reference:

MpInstance.finish


function MpInstance.finish() ->  MpResult {
    log = string?,
    term = string?,
    error = string?,
    status = MpResultStatus,
    fig = MpFig[]?,
}

Finish a metapost instance.

If for some reason you want to stop using an MPlib instance while processing is not yet actually done, you can call finish. Eventually, used memory will be freed and open files will be closed by the Lua garbage collector, but an explicit finish is the only way to capture the final part of the output streams.

Reference:

MpInstance.char_width


function MpInstance.char_width(
  fontname: string,
  char: integer
) -> width number

@return width - AFM units

😱 Types incomplete or incorrect? πŸ™ Please contribute!

Report a character's width.

This function finds the size of a glyph in a defined font. The fontname is the same name as the argument to infont; the char is a glyph id in the range 0 to 255; the returned width is in AFM units.

Reference:

MpInstance.char_height


function MpInstance.char_height(
  fontname: string,
  char: integer
) -> height number

@return height - FM units

😱 Types incomplete or incorrect? πŸ™ Please contribute!

Report a character's height.

This function finds the size of a glyph in a defined font. The fontname is the same name as the argument to infont; the char is a glyph id in the range 0 to 255; the returned height is in AFM units.

Reference:

MpInstance.char_depth


function MpInstance.char_depth(
  fontname: string,
  char: integer
) -> depth number

@return depth - AFM units

😱 Types incomplete or incorrect? πŸ™ Please contribute!

Report a character's depth.

This function finds the size of a glyph in a defined font. The fontname is the same name as the argument to infont; the char is a glyph id in the range 0 to 255; the returned depth is in AFM units.

Reference:

MpInstance.get_boolean


function MpInstance.get_boolean(name: string) -> value boolean

Reference:

MpInstance.get_numeric


function MpInstance.get_numeric(name: string) -> value integer

Reference:

MpInstance.get_string


function MpInstance.get_string(name: string) -> value string

Reference:

MpInstance.get_path


function MpInstance.get_path(name: string) -> value table

Reference:

MpInstance.solve_path


function MpInstance.solve_path(
  coordinates: table,
  cyclic: boolean
)

Reference:

😱 Types incomplete or incorrect? πŸ™ Please contribute!