GML Squish text after two lines

T

Topper1

Guest
Hello

I am drawing text into a sprite box of a fixed size, 1200 pixels wide and enough room for 2 lines of text.
I am using the following to wrap the text so it is not drawn off the sides of the sprite
Code:
draw_text_ext(x,y,thisText,-1,1200)
where x,y is the centre of the sprite and thisText is the string to draw.
The font is set to align middle and centre.

What I need, however, is that when the text cannot fit on two lines, that is it will be drawn onto three lines, is for the drawn text to be thinner/squished, to ensure the full string is drawn on two lines. In other words, the font size to be decreased horizontally only.

I've tried a few attempts but no success.
Does anyone who is more knowledgeable with algorithms offer any assistance.
Any help with this would be much appreciated :)
 

NightFrost

Member
You cannot adjust text within a single draw call. You need to measure your text using string_width() and cut it in two where its length goes over two lines. Then draw first part with one draw settings, the second with other draw settings.
 
Top