1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GML Squish text after two lines

Discussion in 'Programming' started by Topper1, Mar 12, 2019.

  1. Topper1

    Topper1 Member

    Joined:
    Jul 12, 2016
    Posts:
    1
    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 :)
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    2,092
    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.
     

Share This Page