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


GML Code Example

string_height_ext(string, sep, w);

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

Returns: Real


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.


GML Code 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: Strings

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here