Skip to content

string_height_ext

CryoEagle edited this page Dec 26, 2018 · 2 revisions

string_height_ext

Returns the height in pixels of a string based on the given separation and line-break width.

Syntax:

string_height_ext(str, sep, w)
Argument Description
string str The string to measure the height of
int sep The distance in pixels between lines of text as if the string was being drawn
int w The maximum width (in pixels) of the string before a line break as if the string was being drawn

Returns: Real

Description

This function will return the height (in pixels) of the input string, taking into account the line separation and line-break width (which is defined as the number of pixels that the string can occupy before a line break is inserted). It is very handy for calculating distances between text elements based on the tallest of the letters that make up the string as well as the actual string length itself when spread over several lines as it would be drawn with draw_text_ext using the currently defined font. Separation and width can be set to -1 to get the default spacing.

Example:

var hh;
hh = string_height_ext(str_Story_Text[1], -1, 100);
draw_text_ext(32, 32, str_Story_Text[1], -1, 100);
draw_text_ext(32, 32 + hh, str_Story_Text[2], -1, 100);

The above code will get the height of the given string, taking into account the line separation and line-break width, and then draw two lines of text, using the returned total string height as a separator.

Back to strings

Clone this wiki locally