jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.27k stars 454 forks source link

Add Two.Text.direction property #719

Closed jonobr1 closed 6 months ago

jonobr1 commented 6 months ago

This PR introduces text direction to the Two.Text class. Now, you can specify if text is rendered from left to right or right to left. This is helpful for working with more languages, such as:

Example usage:

const str = "تا زمانی که متوقف نشوید، مهم نیست که چقدر آهسته حرکت می کنید.";
const text = new Two.Text(str, two.width - 10, 50);
text.direction = 'rtl'; // Default is 'ltr'