From 9e18f855cc23067211cd87991cb9fc28ad8d345e Mon Sep 17 00:00:00 2001 From: Christopher Overbeck Date: Wed, 16 Sep 2026 19:44:06 -0500 Subject: [PATCH] fix(dimension): size a limits stack from the MText stack layout The fit and break estimates used two halves at STACK_HALF_SCALE; the stack is laid out from the lower half's baseline to the upper half's cap, which is STACK_RAISE + STACK_HALF_SCALE of the run height. The taller estimate flips arrows outside for a few more stacked texts that AutoCAD drew that way. --- src/entities/dimension.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/entities/dimension.rs b/src/entities/dimension.rs index 36bb67687..72033e970 100644 --- a/src/entities/dimension.rs +++ b/src/entities/dimension.rs @@ -6733,10 +6733,14 @@ fn dimension_text_extent_height(dim: &Dimension, style: Option<&DimStyle>, text_ fn dimension_text_block_height(style: Option<&DimStyle>, text_height: f64) -> f64 { match style { Some(s) if s.dimlim => { + // From the lower half's baseline to the upper half's cap, as the + // MText stack lays them out. text_height * dimtfac_or_one(s) - * 2.0 - * f64::from(crate::entities::text_support::STACK_HALF_SCALE) + * f64::from( + crate::entities::text_support::STACK_RAISE + + crate::entities::text_support::STACK_HALF_SCALE, + ) } _ => text_height, } @@ -8515,7 +8519,12 @@ mod limits_format_tests { assert_eq!(dimension_text_block_height(Some(&s), 2.0), 2.0); s.dimlim = true; s.dimtfac = 0.5; - let expected = 2.0 * 0.5 * 2.0 * f64::from(crate::entities::text_support::STACK_HALF_SCALE); + let expected = 2.0 + * 0.5 + * f64::from( + crate::entities::text_support::STACK_RAISE + + crate::entities::text_support::STACK_HALF_SCALE, + ); assert_eq!(dimension_text_block_height(Some(&s), 2.0), expected); } }