gre.get string size

gre.get_string_size(
    font,
    font_size,
    string,
    width,
    data
)
            

Calculate the area in pixels which the given string will occupy on the screen.

This call can only be made from the main Lua action execution thread.

Parameters: font   The name of the font to render in font_size   The size of the font to render in   string   The string to render width A clipping width (in pixels) for the string, used to calculate how many characters fit data A table containing additional options. Valid options are: ["length"] - number of characters to process ["spacing"] - letter spacing parameter ["wrapping"] - boolean to activate wrapping logic Returns: A table with the following: "width" width of the widest line in the body of text "height" total height of the wrapped text in pixels "n_lines" number of lines the text fills when wrapped A snippet of it in use: local t = gre.get_string_size('fonts/Roboto-ThinItalic.ttf', 72, 'How long is this string?', 600, {["wrapping"] = true} )

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.