You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to draw vertical text lines with font family? #7313
I tried to write each char, effect is as follows, and it seems not as good as horizontal text draw, any direct vertical line draw method?
Some chars are not aligned in the middle.
ImageDraw.text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False)[source]
Draws the string at the given position.
PARAMETERS:
xy – The anchor coordinates of the text.
text – String to be drawn. If it contains any newline characters, the text is passed on to multiline_text().
The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left. See Text anchors for valid values. This parameter is ignored for non-TrueType fonts.
Note
This parameter was present in earlier versions of Pillow, but implemented only in version 8.0.0.
spacing – If the text is passed on to multiline_text(), the number of pixels between lines.
align – If the text is passed on to multiline_text(), "left", "center" or "right". Determines the relative alignment of lines. Use the anchor parameter to specify the alignment to xy.
direction –
Direction of the text. It can be "rtl" (right to left), "ltr" (left to right) or "ttb" (top to bottom). Requires libraqm.
New in version 4.2.0.
features –
A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example "dlig" or "ss01", but can be also used to turn off default font features, for example "-liga" to disable ligatures or "-kern" to disable kerning. To get all supported features, see OpenType docs. Requires libraqm.
New in version 4.2.0.
language –
Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a BCP 47 language code. Requires libraqm.
New in version 6.0.0.
stroke_width –
The width of the text stroke.
New in version 6.2.0.
stroke_fill –
Color to use for the text stroke. If not given, will default to the fill parameter.
New in version 6.2.0.
embedded_color –
Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
New in version 8.0.0.
ImageDraw.multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False)[source]
Draws the string at the given position.
PARAMETERS:
xy – The anchor coordinates of the text.
The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left. See Text anchors for valid values. This parameter is ignored for non-TrueType fonts.
Note
This parameter was present in earlier versions of Pillow, but implemented only in version 8.0.0.
spacing – The number of pixels between lines.
align – "left", "center" or "right". Determines the relative alignment of lines. Use the anchor parameter to specify the alignment to xy.
direction –
Direction of the text. It can be "rtl" (right to left), "ltr" (left to right) or "ttb" (top to bottom). Requires libraqm.
New in version 4.2.0.
features –
A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example "dlig" or "ss01", but can be also used to turn off default font features, for example "-liga" to disable ligatures or "-kern" to disable kerning. To get all supported features, see OpenType docs. Requires libraqm.
New in version 4.2.0.
language –
Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a BCP 47 language code. Requires libraqm.
New in version 6.0.0.
stroke_width –
The width of the text stroke.
New in version 6.2.0.
stroke_fill –
Color to use for the text stroke. If not given, will default to
the fill parameter.
New in version 6.2.0.
embedded_color –
Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
Activity
nissansz commentedon Aug 2, 2023
I tried to write each char, effect is as follows, and it seems not as good as horizontal text draw, any direct vertical line draw method?
Some chars are not aligned in the middle.
radarhere commentedon Aug 2, 2023
There is the "direction" parameter of ImageDraw's
text()method - https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html#PIL.ImageDraw.ImageDraw.textnissansz commentedon Aug 2, 2023
Thank you, what is effect of embedded color?
ImageDraw.text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False)[source]
Draws the string at the given position.
PARAMETERS:
xy – The anchor coordinates of the text.
text – String to be drawn. If it contains any newline characters, the text is passed on to multiline_text().
fill – Color to use for the text.
font – An ImageFont instance.
anchor –
The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left. See Text anchors for valid values. This parameter is ignored for non-TrueType fonts.
Note
This parameter was present in earlier versions of Pillow, but implemented only in version 8.0.0.
spacing – If the text is passed on to multiline_text(), the number of pixels between lines.
align – If the text is passed on to multiline_text(), "left", "center" or "right". Determines the relative alignment of lines. Use the anchor parameter to specify the alignment to xy.
direction –
Direction of the text. It can be "rtl" (right to left), "ltr" (left to right) or "ttb" (top to bottom). Requires libraqm.
New in version 4.2.0.
features –
A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example "dlig" or "ss01", but can be also used to turn off default font features, for example "-liga" to disable ligatures or "-kern" to disable kerning. To get all supported features, see OpenType docs. Requires libraqm.
New in version 4.2.0.
language –
Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a BCP 47 language code. Requires libraqm.
New in version 6.0.0.
stroke_width –
The width of the text stroke.
New in version 6.2.0.
stroke_fill –
Color to use for the text stroke. If not given, will default to the fill parameter.
New in version 6.2.0.
embedded_color –
Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
New in version 8.0.0.
ImageDraw.multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False)[source]
Draws the string at the given position.
PARAMETERS:
xy – The anchor coordinates of the text.
text – String to be drawn.
fill – Color to use for the text.
font – An ImageFont instance.
anchor –
The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left. See Text anchors for valid values. This parameter is ignored for non-TrueType fonts.
Note
This parameter was present in earlier versions of Pillow, but implemented only in version 8.0.0.
spacing – The number of pixels between lines.
align – "left", "center" or "right". Determines the relative alignment of lines. Use the anchor parameter to specify the alignment to xy.
direction –
Direction of the text. It can be "rtl" (right to left), "ltr" (left to right) or "ttb" (top to bottom). Requires libraqm.
New in version 4.2.0.
features –
A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example "dlig" or "ss01", but can be also used to turn off default font features, for example "-liga" to disable ligatures or "-kern" to disable kerning. To get all supported features, see OpenType docs. Requires libraqm.
New in version 4.2.0.
language –
Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a BCP 47 language code. Requires libraqm.
New in version 6.0.0.
stroke_width –
The width of the text stroke.
New in version 6.2.0.
stroke_fill –
Color to use for the text stroke. If not given, will default to
the fill parameter.
New in version 6.2.0.
embedded_color –
Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
radarhere commentedon Aug 2, 2023
Embedded color is for fonts that have colors inside them. In #4955, an example of this is fonts that include emojis.

nissansz commentedon Aug 2, 2023
Thank you.