Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌍 Add RTL Text Support for Canvas and SDF Font Renderers (Arabic, Hebrew, etc.) #475

Open
wouterlucas opened this issue Jan 7, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@wouterlucas
Copy link
Contributor

🌟 Feature Request: RTL Text Support in Font Engines

🚀 Goal

Support for Right-to-Left (RTL) text rendering is essential to accommodate languages like Arabic, Hebrew, and others 🌍. Currently, RTL rendering is not natively supported in the following font engines:

  • 🖌️ Canvas Text Renderer
  • ✍️ SDF Font Renderer

This feature will enable proper text alignment, glyph shaping, and directionality for RTL languages.

🔧 Suggested Implementation

  • Add RTL text layout logic to both renderers.
  • Integrate glyph shaping for languages with complex scripts (e.g., Arabic ligatures).
  • Provide an API for switching between LTR and RTL modes on CoreTextNode.

🛠️ Resources

@wouterlucas wouterlucas added the enhancement New feature or request label Jan 7, 2025
@elsassph
Copy link
Contributor

elsassph commented Jan 7, 2025

It is important to note that the Lightning 2 PR is NOT a good reference:

  • It has poor Chrome compatibility (77+)
  • It doesn't support bidirectional text wrapping (mixed English and Arabic)

https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/direction#browser_compatibility

@wouterlucas
Copy link
Contributor Author

That's good to know, we'll have to come up with a SDF one anyway, might see if we can port some of that processing over to the way canvas text is constructed (if possible).

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants