Draws formatted text, with word wrap and alignment.
See additional notes in love.graphics.print.
The word wrap limit is applied before any scaling, rotation, and other coordinate transformations. Therefore the amount of text per line stays constant given the same wrap limit, even if the scale arguments change.
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.
In versions prior to 11.0, color and byte component values were within the range of 0 to 255 instead of 0 to 1.
![]() |
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. |
![]() |
Text may appear blurry if it's rendered at non-integer pixel locations. |
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 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( text, font, x, y, limit, align, r, sx, sy, ox, oy, kx, ky )
string text
Font font
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 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( text, transform, limit, align )
string text
Transform transform
number limit
AlignMode align ("left")
Nothing.
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( text, font, transform, limit, align )
string text
Font font
Transform transform
number limit
AlignMode align ("left")
Nothing.
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( coloredtext, x, y, limit, align, 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 limit
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.
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( coloredtext, font, x, y, limit, align, 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 ...
Font font
number x
number y
number limit
AlignMode align ("left")
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.
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( coloredtext, transform, limit, align )
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 ...
Transform transform
number limit
AlignMode align ("left")
Nothing.
The color set by love.graphics.setColor will be combined (multiplied) with the colors of the text.
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
love.graphics.printf( coloredtext, font, transform, limit, align )
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 ...
Font font
Transform transform
number limit
AlignMode align ("left")
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