cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
885 stars 36 forks source link

Bing Bong your rtl text handling is wrong #455

Closed emilyyyylime closed 9 months ago

emilyyyylime commented 9 months ago

Image of low quality tweet header as appears in "you've been hit by / you've been struck by / truck" meme You've been hit by- You've been struck by- RTL DOCUMENTS

Image of the triplet of the 'Nobody expects the Spanish inquisition' meme. Sorry I don't know the source NOBODY EXPECTS Right-To-Left documents

I can continue all day
But I probably shouldn't

#import "@preview/cetz:0.1.2": canvas, draw

#set text(dir: ltr)
#canvas({
  import draw: *
  circle((0,0), radius: 1)
  line((0,0), (180deg, 1))
})

#set text(dir: rtl)
#canvas({
  import draw: *
  circle((0,0), radius: 1)
  line((0,0), (180deg, 1))
})

Rendered using Typst-Renderer on the official Typst Discord server; https://discord.com/channels/1054443721975922748/1056574658771681361/1196709166778175628

This at first looks intended but indeed it makes no sense, as both should be 180 degrees from the positive X axis. Additionally, in right-to-left documents, 0deg appears the exact same as above, so indeed polar points are very much Broken™

johannes-wolf commented 9 months ago

There is currently no way to query Typst for the text direction, so this can not yet get fixed. The canvas function could call set text(direction: ltr), maybe that is an option for now?

fenjalien commented 9 months ago

The canvas function could call set text(direction: ltr)

That would effect any content elements though. I would suggest using scale((x: -1)) but it seems to not work in this case...

emilyyyylime commented 9 months ago

There is currently no way to query Typst for the text direction, so this can not yet get fixed. The canvas function could call set text(direction: ltr), maybe that is an option for now?

I don't quite know how the library works, perhaps there's an inappropriate use of start or end somewhere, or one of plenty of other constructs that could be rewritten in a more 'absolute' sense; but in the case that there truly is no better solution, I would prefer an automatic set text(dir: ltr). If CeTZ itself isn't working, I sure won't be putting any content inside of it, so we should at the very least get CeTZ working.

johannes-wolf commented 9 months ago

Should be fixed with the linked PR.