tldraw / tldraw

SDK for creating whiteboards and canvas experiences on the web.
https://tldraw.dev
Other
33.04k stars 1.98k forks source link

textfields: fix RTL layout for SVG exports #3680

Closed mimecuvalo closed 2 weeks ago

mimecuvalo commented 2 weeks ago

Followup to https://github.com/tldraw/tldraw/pull/3188 (although this problem was there before that PR)

This does more work for RTL rendering in SVG context, especially since we position each span one-by-one.

I had to do a bit of esoteric spelunking and it turns out unicode-bidi: plaintext solves our issue even though it isn't really recommend to be used by web developers. Fun times πŸ™ƒ

Before:

Screenshot 2024-05-02 at 11 45 44

After:

Screenshot 2024-05-02 at 11 54 48

Change Type

Test Plan

  1. Test LTR text.
  2. Test RTL text.
  3. Test mixed LTR/RTL on different lines.

Release Notes

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
examples βœ… Ready (Inspect) Visit Preview May 3, 2024 0:17am
1 Ignored Deployment | Name | Status | Preview | Updated (UTC) | | :--- | :----- | :------ | :------ | | **tldraw-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/tldraw/tldraw-docs/AjtJVFn1u3DiggT1CBfMaetcVsuN)) | [Visit Preview](https://tldraw-docs-git-mime-rtl-svg-export-tldraw.vercel.app) | May 3, 2024 0:17am |
steveruizok commented 2 weeks ago

Updating the snapshots here (as I recently learned, we can trigger an update in CI by adding the "update snapshots" tag)

hossain666 commented 2 weeks ago

https://github.com/apple/swift/blob/main/utils/pygments/swift.py[__](https://github.com/apple/swift/blob/main/utils/pygments/swift.py)