-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
[Feature Request] Content-Relative Anchors #683
Comments
I think we can create those anchors for |
Can one access them in the current version using the snippet you provided? And if so, what are the called? |
No, we do not create them yet. How are you using |
As it stands I'm using |
So all you want is "unpadded" anchors of the contents bounding box (more or less)? |
Roughly, the most important feature to me is that the anchors are on the same height as the baseline of the content. This makes drawing things such that text lines up across multiple parts much easier. I'm not sure if that is exactly what you meant just now. |
Not exactly, as Typst does not give access to the baseline. So no, this cannot be implemented right now. |
Ok, I'm looking forward to whenever the folks over at Typst get around to implementing external access to such properties. |
Wait… it should work. |
Without setting the |
Or do the horizontal anchors naturally fall along the baseline of included text? |
Yes, but only if padding is |
So what cetz needs to do, is to expose the bounding box anchors of the content without the padding applied. |
Seems so. As long as the natural aligning of the baseline to the |
No, Line 805 in b334fef
|
Ah, I see. I guess this means waiting for Typst to properly expose these measurements/properties? |
But you can get what you want with a workaround, I guess: #import "@preview/cetz:0.2.2"
#set page(width: auto, height: auto)
#let content2(..args, anchor: none, name: none, padding: 0) = {
cetz.draw.group(name: name, anchor: anchor, {
cetz.draw.group(name: "tmp-group", padding: padding, {
cetz.draw.content(..args, name: "content")
})
cetz.draw.rect("tmp-group.south-west", "tmp-group.north-east")
cetz.draw.anchor("baseline-west", ("tmp-group.content.south-west", "-|", "tmp-group.west"))
cetz.draw.anchor("baseline-east", ("tmp-group.content.south-east", "-|", "tmp-group.east"))
})
}
#cetz.canvas({
import cetz.draw: *
content2((0, 10), [Alle Autos!], anchor: "south", padding: 1, name: "a")
content2("a.baseline-east", [geile Autos, yeah! \ geniaiaeaeiaenein],
anchor: "baseline-west")
}) So you can implement this feature via cetz itself :) |
Wow! I'll need to give that a try a soon as I'm back in front of my machine. |
@johannes-wolf Your workaround works nicely, thank you very much! But I believe it works since—and forgive me if I don't have the proper Typst terminology down—the As an aside, I'm bewilder by the fact that Typst doesn't automatically choose the smallest possible settings for |
Though not particularly relevant to this issue if found a resolution to the aside in my previous comment. Typst also supports |
@timfi Yes, I think Typsts |
Would it be possible to instead measure twice with different settings for text edge? |
That should work, yes. |
PR is ready. |
Cetz currently doesn't support anchors whose position is relative to the properties of a nodes content—see
base*
,mid*
, andtext
in the image below.(Credits to Packt for the image.)
After a short, productive discussion with @fenjalien (see #680), it turns out that:
The text was updated successfully, but these errors were encountered: