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.

{{notice|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.}}
{{notice|Text may appear blurry if it's rendered at non-integer pixel locations.}}
== 関数 ==
=== 概要 ===
<source lang="lua">
love.graphics.printf( text, x, y, limit, align, r, sx, sy, ox, oy, kx, ky )
</source>
=== 引数 ===
{{param (日本語)|string|text|A text string.}}
{{param (日本語)|number|x|The position on the x-axis.}}
{{param (日本語)|number|y|The position on the y-axis.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
{{New feature (日本語)|0.9.0|
{{param (日本語)|number|r (0)|Orientation (radians).}}
{{param (日本語)|number|sx (1)|Scale factor (x-axis).}}
{{param (日本語)|number|sy (sx)|Scale factor (y-axis).}}
{{param (日本語)|number|ox (0)|Origin offset (x-axis).}}
{{param (日本語)|number|oy (0)|Origin offset (y-axis).}}
{{param (日本語)|number|kx (0)|Shearing factor (x-axis).}}
{{param (日本語)|number|ky (0)|Shearing factor (y-axis).}}
}}
=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( text, font, x, y, limit, align, r, sx, sy, ox, oy, kx, ky )
</source>
=== 引数 ===
{{param (日本語)|string|text|A text string.}}
{{param (日本語)|Font|font|The Font object to use.}}
{{param (日本語)|number|x|The position on the x-axis.}}
{{param (日本語)|number|y|The position on the y-axis.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
{{param (日本語)|number|r (0)|Orientation (radians).}}
{{param (日本語)|number|sx (1)|Scale factor (x-axis).}}
{{param (日本語)|number|sy (sx)|Scale factor (y-axis).}}
{{param (日本語)|number|ox (0)|Origin offset (x-axis).}}
{{param (日本語)|number|oy (0)|Origin offset (y-axis).}}
{{param (日本語)|number|kx (0)|Shearing factor (x-axis).}}
{{param (日本語)|number|ky (0)|Shearing factor (y-axis).}}
=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( text, transform, limit, align )
</source>
=== 引数 ===
{{param (日本語)|string|text|A text string.}}
{{param (日本語)|Transform|transform|Transformation object.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( text, font, transform, limit, align )
</source>
=== 引数 ===
{{param (日本語)|string|text|A text string.}}
{{param (日本語)|Font|font|The Font object to use.}}
{{param (日本語)|Transform|transform|Transformation object.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[0.10.0 (日本語)|0.10.0]]|100|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( coloredtext, x, y, limit, align, angle, sx, sy, ox, oy, kx, ky )
</source>
=== 引数 ===
{{param (日本語)|table|coloredtext|A table containing colors and strings to add to the object, in the form of <code>{color1, string1, color2, string2, ...}</code>.}}
{{subparam|table|color1|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string1|A string of text which has a color specified by the previous color.}}
{{subparam|table|color2|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string2|A string of text which has a color specified by the previous color.}}
{{subparam|tables and strings|...|Additional colors and strings.}}
{{param (日本語)|number|x|The position of the text (x-axis).}}
{{param (日本語)|number|y|The position of the text (y-axis).}}
{{param (日本語)|number|limit|The maximum width in pixels of the text before it gets automatically wrapped to a new line.}}
{{param (日本語)|AlignMode|align|The alignment of the text.}}
{{param (日本語)|number|angle (0)|Orientation (radians).}}
{{param (日本語)|number|sx (1)|Scale factor (x-axis).}}
{{param (日本語)|number|sy (sx)|Scale factor (y-axis).}}
{{param (日本語)|number|ox (0)|Origin offset (x-axis).}}
{{param (日本語)|number|oy (0)|Origin offset (y-axis).}}
{{param (日本語)|number|kx (0)|Shearing / skew factor (x-axis).}}
{{param (日本語)|number|ky (0)|Shearing / skew factor (y-axis).}}
=== 返値 ===
ありません。
=== 注釈 ===
The color set by [[love.graphics.setColor]] will be combined (multiplied) with the colors of the text.

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( coloredtext, font, x, y, limit, align, angle, sx, sy, ox, oy, kx, ky )
</source>
=== 引数 ===
{{param (日本語)|table|coloredtext|A table containing colors and strings to add to the object, in the form of <code>{color1, string1, color2, string2, ...}</code>.}}
{{subparam|table|color1|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string1|A string of text which has a color specified by the previous color.}}
{{subparam|table|color2|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string2|A string of text which has a color specified by the previous color.}}
{{subparam|tables and strings|...|Additional colors and strings.}}
{{param (日本語)|Font|font|The Font object to use.}}
{{param (日本語)|number|x|The position on the x-axis.}}
{{param (日本語)|number|y|The position on the y-axis.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
{{param (日本語)|number|angle (0)|Orientation (radians).}}
{{param (日本語)|number|sx (1)|Scale factor (x-axis).}}
{{param (日本語)|number|sy (sx)|Scale factor (y-axis).}}
{{param (日本語)|number|ox (0)|Origin offset (x-axis).}}
{{param (日本語)|number|oy (0)|Origin offset (y-axis).}}
{{param (日本語)|number|kx (0)|Shearing factor (x-axis).}}
{{param (日本語)|number|ky (0)|Shearing factor (y-axis).}}
=== 返値 ===
ありません。
=== 注釈 ===
The color set by [[love.graphics.setColor]] will be combined (multiplied) with the colors of the text.

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( coloredtext, transform, limit, align )
</source>
=== 引数 ===
{{param (日本語)|table|coloredtext|A table containing colors and strings to add to the object, in the form of <code>{color1, string1, color2, string2, ...}</code>.}}
{{subparam|table|color1|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string1|A string of text which has a color specified by the previous color.}}
{{subparam|table|color2|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string2|A string of text which has a color specified by the previous color.}}
{{subparam|tables and strings|...|Additional colors and strings.}}
{{param (日本語)|Transform|transform|Transformation object.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
=== 返値 ===
ありません。
=== 注釈 ===
The color set by [[love.graphics.setColor]] will be combined (multiplied) with the colors of the text.

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
=== 概要 ===
<source lang="lua">
love.graphics.printf( coloredtext, font, transform, limit, align )
</source>
=== 引数 ===
{{param (日本語)|table|coloredtext|A table containing colors and strings to add to the object, in the form of <code>{color1, string1, color2, string2, ...}</code>.}}
{{subparam|table|color1|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string1|A string of text which has a color specified by the previous color.}}
{{subparam|table|color2|A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of <code>{red, green, blue, alpha}</code>.}}
{{subparam|string|string2|A string of text which has a color specified by the previous color.}}
{{subparam|tables and strings|...|Additional colors and strings.}}
{{param (日本語)|Font|font|The Font object to use.}}
{{param (日本語)|Transform|transform|Transformation object.}}
{{param (日本語)|number|limit|Wrap the line after this many horizontal pixels.}}
{{param (日本語)|AlignMode|align ("left")|The alignment.}}
=== 返値 ===
ありません。
=== 注釈 ===
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.
<source lang="lua">
love.graphics.printf("This text is aligned right, and wraps when it gets too big.", 25, 25, 125, "right")
</source>
== 注釈 ==
Note that the limit argument affects the position of your text for 'center' and 'right' alignment.
<source lang="lua">
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
</source>
== 関連 ==
* [[parent::love.graphics (日本語)]]
* [[Font:getWrap (日本語)]]
[[Category:Functions (日本語)]]
[[Sub-Category::Drawing (日本語)| ]]
{{#set:Description=Draws formatted text, with word wrap and alignment.}}
{{#set:Since=000}}

== そのほかの言語 ==
{{i18n (日本語)|love.graphics.printf}}