Draws formatted text, with word wrap and alignment.
See additional notes in love.graphics.print.
In version 0.9.2 and earlier, wrapping was implemented by breaking up words by spaces and putting them back together to make sure things fit nicely within the limit provided. However, due to the way this is done, extra spaces between words would end up missing when printed on the screen, and some lines could overflow past the provided wrap limit. In version 0.10.0 and newer this is no longer the case.
Aligning does not work as one might expect! It doesn't align to the x/y coordinates given, but in a rectangle, where the limit is the width.
love.graphics.printf( text, x, y, limit, align )
string text
number x
number y
number limit
AlignMode align ("left")
Nothing.
Available since LÖVE 0.9.0
This variant is not supported in earlier versions.
love.graphics.printf( text, x, y, limit, align, r, sx, sy, ox, oy, kx, ky )
string text
number x
number y
number limit
AlignMode align ("left")
number r (0)
number sx (1)
number sy (sx)
number ox (0)
number oy (0)
number kx (0)
number ky (0)
Nothing.
Available since LÖVE 0.10.0
This variant is not supported in earlier versions.
love.graphics.printf( coloredtext, x, y, wraplimit, alignmode, angle, sx, sy, ox, oy, kx, ky )
table coloredtext
{color1, string1, color2, string2, ...}
. table color1
{red, green, blue, alpha}
.string string1
table color2
{red, green, blue, alpha}
.string string2
tables and strings ...
number x
number y
number wraplimit
AlignMode align
number angle (0)
number sx (1)
number sy (sx)
number ox (0)
number oy (0)
number kx (0)
number ky (0)
Nothing.
The color set by love.graphics.setColor will be combined (multiplied) with the colors of the text.
Draw text to the screen with right alignment and a horizontal limit of 125.
love.graphics.printf("This text is aligned right, and wraps when it gets too big.", 25, 25, 125, "right")
Note that the limit argument affects the position of your text for 'center' and 'right' alignment.
love.graphics.printf("This text is aligned center",100, 100, 200,"center") -- center your text around x = 200/2 + 100 = 200 love.graphics.printf("This text is aligned right",100, 100, 200,"right") -- align right to x = 100 + 200 = 300
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.printf