Skip to content

Commit 8c52968

Browse files
committed
Add text anchor to content
1 parent 9420574 commit 8c52968

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

src/draw/shapes.typ

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@
742742
/// - **base**: Horizontally centered baseline of the content
743743
/// - **base-east**: Baseline height extended to the east
744744
/// - **base-west**: Baseline height extended to the west
745+
/// - **text**: Position at the content start on the baseline of the content
745746
#let content(
746747
..args-style,
747748
angle: 0deg,
@@ -795,7 +796,7 @@
795796
angle = angle * -1
796797

797798
// Height from the baseline to content-north
798-
let (_, baseline-height) = util.measure(ctx, text(top-edge: "bounds", bottom-edge: "baseline", body))
799+
let (content-width, baseline-height) = util.measure(ctx, text(top-edge: "bounds", bottom-edge: "baseline", body))
799800

800801
// Size of the bounding box
801802
let (width, height, ..) = if auto-size {
@@ -851,6 +852,7 @@
851852
0.5)
852853
let base-east = vector.add(base, east-scaled)
853854
let base-west = vector.add(base, west-scaled)
855+
let text = vector.add(base, vector.scale(east-dir, -content-width / 2))
854856
let mid-east = vector.add(mid, east-scaled)
855857
let mid-west = vector.add(mid, west-scaled)
856858

@@ -862,6 +864,7 @@
862864
base: base,
863865
base-east: base-east,
864866
base-west: base-west,
867+
text: text,
865868
north: north,
866869
north-east: north-east,
867870
north-west: north-west,

tests/content/anchor/ref/1.png

91 Bytes
Loading

tests/content/transform/ref/1.png

183 Bytes
Loading

0 commit comments

Comments
 (0)