fix(text): keep text anchors in f64 and honour space advance

Single-line TEXT and ATTRIB/ATTDEF cast the insertion/alignment point to
f32 before computing the stroke origin. At large coordinates (UTM ~4.5M)
the f32 ulp is ~0.5, snapping text baselines onto a coarse grid so
adjacent rows collapse onto each other and overlap. Keep the anchor in
f64 throughout.

Horizontal alignment now uses the pen advance box [0, advance] instead of
the inked min_x/max_x, so leading/trailing spaces keep their width and
space-aligned columns no longer shift. text_local_bounds returns
TextLocalBounds { ink_min, ink_max, advance }.

TABLE laid out its whole grid in an f32 world frame; switch to a local
f32 frame plus an f64 base added at the widening step, fixing cell-text
baseline snap and the i32 overflow in the border-dedup keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-22 18:47:45 +03:00
1 parent 33314a5889
commit 5291a3fb82
4 files changed
+66 -28

No files matched your search

+9 -7
View File
@@ -255,17 +255,19 @@ fn build_attr_truck(input: AttrTextInputs<'_>, document: &acadrust::CadDocument)
oblique_angle,
);
let (anchor_local_x, anchor_local_y) =
if let Some(([min_x, min_y], [max_x, max_y])) = bounds {
if let Some(b) = bounds {
// Horizontal anchor uses the pen advance box so leading /
// trailing spaces keep their width.
let ax = match input.horizontal_alignment {
AHA::Left => min_x,
AHA::Center | AHA::Middle => (min_x + max_x) * 0.5,
AHA::Right | AHA::Aligned | AHA::Fit => max_x,
AHA::Left => 0.0,
AHA::Center | AHA::Middle => b.advance * 0.5,
AHA::Right | AHA::Aligned | AHA::Fit => b.advance,
};
let ay = match input.vertical_alignment {
AVA::Baseline => 0.0,
AVA::Bottom => min_y,
AVA::Middle => (min_y + max_y) * 0.5,
AVA::Top => max_y,
AVA::Bottom => b.ink_min[1],
AVA::Middle => (b.ink_min[1] + b.ink_max[1]) * 0.5,
AVA::Top => b.ink_max[1],
};
(ax, ay)
} else {