Reference textDirection()

textDirection()

Sets or gets the text drawing direction.

The textDirection() function allows you to specify the direction in which text is rendered on the canvas. When provided with a direction parameter (such as "ltr" for left-to-right, "rtl" for right-to-left, or "inherit"), it updates the renderer's state with that value and applies the new setting. When called without any arguments, it returns the current text direction. This function is particularly useful for rendering text in languages with different writing directions.

Examples

Syntax

textDirection(direction)
textDirection()

Parameters

direction
String: The text direction to set ("ltr", "rtl", or "inherit").

Returns

String: If no arguments are provided, the current text direction, either "ltr", "rtl", or "inherit"
Notice any errors or typos? Please let us know. Please feel free to edit src/type/textCore.js and open a pull request!

Related References