-
-
Notifications
You must be signed in to change notification settings - Fork 18
string_width_ext
Returns the maximum width in pixels of a string based on the given separation and line-break width.
string_width_ext(str, sep, w)
Argument | Description |
---|---|
string str |
The string to measure the width 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
This function will return the maximum width (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 maximum width of a string that is split 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.
var ww;
ww = string_width_ext(str_Story_Text[1], -1, 100);
draw_text_ext(32, 32, str_Story_Text[1], -1, 100);
draw_text_ext(32 + ww, 32, str_Story_Text[2], -1, 100);
The above code will get the width 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 width as a separator.
Back to strings