From 5ccaaad48e75564dfae3ade57b6b008882a481cd Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 28 Sep 2026 19:16:05 +0300 Subject: [PATCH] fix(text): Middle-justified TEXT centres vertically on half its height Middle (72 = 4) carries a Baseline vertical code, so the baseline landed on the alignment point and the text sat half a height too high. Fixes #767 Co-Authored-By: Claude Opus 5.5 --- src/entities/text.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/entities/text.rs b/src/entities/text.rs index bc4b1a74b..f6ba95ed8 100644 --- a/src/entities/text.rs +++ b/src/entities/text.rs @@ -316,7 +316,10 @@ pub fn text_run_placement_at_scale( HA::Aligned | HA::Fit => 0.0, }; // Vertical anchor uses the inked extent (cap / baseline geometry). + // `Middle` (72 = 4) centres on half the text height whatever its + // vertical code says; its baseline sits h/2 below the point. (#767) let ay = match t.vertical_alignment { + _ if matches!(t.horizontal_alignment, HA::Middle) => height * 0.5, VA::Baseline => 0.0, VA::Bottom => b.ink_min[1], VA::Middle => (b.ink_min[1] + b.ink_max[1]) * 0.5,