Skip to content

global mplib


methods


mplib.new


function mplib.new(args: MpArguments?) ->  MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
}

Create a new metapost instance.

Reference:

mplib.statistics


function mplib.statistics(mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
}) ->  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:

mplib.execute


function mplib.execute(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  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:

mplib.finish


function mplib.finish(mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
}) ->  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:

mplib.fields


function mplib.fields(obj: MpGraphicObject {
    type = string,
}) ->  string[]

Get the list of accessible values for a particular object.

Reference:

mplib.pen_info


function mplib.pen_info(obj: MpGraphicObject {
    type = string,
}) ->  PenInfo?

Reference:

mplib.char_width


function mplib.char_width(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  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:

mplib.char_height


function mplib.char_height(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  fontname: string,
  char: integer
) -> height number

@return height - AFM 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:

mplib.char_depth


function mplib.char_depth(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  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:

mplib.get_boolean


function mplib.get_boolean(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  name: string
) -> value boolean

Reference:

mplib.get_numeric


function mplib.get_numeric(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  name: string
) -> value integer

Reference:

mplib.get_string


function mplib.get_string(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  name: string
) -> value string

Reference:

mplib.get_path


function mplib.get_path(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  name: string
) -> value table

Reference:

mplib.version


function mplib.version() -> version string

@return version - for example 2.02

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

Return the version of the MetaPost library.

Reference:

mplib.solve_path


function mplib.solve_path(
  mp: MpInstance {
    statistics = function,
    execute = function,
    finish = function,
    char_width = function,
    char_height = function,
    char_depth = function,
    get_boolean = function,
    get_numeric = function,
    get_string = function,
    get_path = function,
    solve_path = function,
},
  coordinates: table,
  cyclic: boolean
)

Reference:

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