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
733 stars 34 forks source link

`draw.content` seems to break `rotate(reflow: true)` #604

Closed Jollywatt closed 1 month ago

Jollywatt commented 1 month ago

This is better shown than explained:

#import "@preview/cetz:0.2.2"

#let obj = rect(rotate(30deg, reflow: true)[hello])

#obj

#cetz.canvas({
  cetz.draw.content(
    (0,0),
    obj
  )
})
Screenshot 2024-05-24 at 00 01 57

I assume we expect the both the bare obj and the obj drawn in a cetz canvas to be the same. (Unless I am mistaken, and this is a result of some styles being applied within cetz.canvas?) Either way, it beats me...

Jollywatt commented 1 month ago

Update: I think this is an issue with rotate(reflow: true) and measure() (mis)interacting:

#set rect(inset: 0pt, stroke: red)

#let obj = rotate(30deg, reflow: true)[hello]

#rect(obj)

#context rect(
  width: measure(obj).width,
  height: measure(obj).height,
  obj,
)
Screenshot 2024-05-24 at 00 44 06

I would assume these results should match.

@laurmaedje is this an issue for the Typst compiler?

laurmaedje commented 1 month ago

This doesn't look ideal indeed. You can open an issue.

johannes-wolf commented 1 month ago

@Jollywatt: You can use content's angle: <angle> for rotating cetz content.

johannes-wolf commented 1 month ago

Closing this, as it is not a cetz issue.