From db43c21d55791e4a1774fd97a38412f6a77e7972 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 8 Aug 2026 02:45:59 +0300 Subject: [PATCH] fix(annotative): scale text by its own annotativeness, not its style's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An annotative object is drawn at the annotation scale only for the scales it has a representation for. Text was being scaled whenever its text style carried the annotative flag, whether or not the text itself had any representation at all. A drawing of twenty floors here has 1144 pieces of text on a style someone flagged annotative and no object contexts anywhere. At 1:100 they were drawn a hundred times too tall — a 411-unit height reaching 41067 — while every other style in the same drawing stayed put. `is_annotative` already said the right thing, and said why: a text style can be turned annotative long after text was drawn in it, and that text keeps its stored height until it is explicitly converted. The scale resolver contradicted it. Text now scales on its own annotativeness alone: an object context, a legacy XDATA marker, or the entity's flag. Dimensions, leaders, tolerances and tables are unchanged — there the style is the standard signal and still counts on its own. Co-Authored-By: Claude Opus 5 --- src/scene/annotative.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/scene/annotative.rs b/src/scene/annotative.rs index 2f27fa195..2badd3a72 100644 --- a/src/scene/annotative.rs +++ b/src/scene/annotative.rs @@ -641,7 +641,25 @@ pub fn effective_annotation_scale_for( ) -> f32 { let context_annotative = is_annotative(doc, entity); let style_annotative = annotation_style_is_annotative(doc, entity); - if !context_annotative && !style_annotative { + // An annotative object is scaled at the scales it has a representation + // for. Text is the case where the style alone proves nothing: a text style + // can be turned annotative long after text was drawn in it, and that text + // keeps its stored height until it is explicitly converted — which is what + // `is_annotative` already says by ignoring the style for TEXT. Scaling on + // the style regardless contradicted it, and a drawing whose text sits on a + // style someone flagged annotative, with no object contexts anywhere, came + // out at the whole annotation scale too large. + // + // A dimension, leader, tolerance or table is different: there the style is + // the standard signal and still counts on its own. + let text_like = matches!( + entity, + EntityType::Text(_) + | EntityType::MText(_) + | EntityType::AttributeEntity(_) + | EntityType::AttributeDefinition(_) + ); + if !context_annotative && (text_like || !style_annotative) { return 1.0; } @@ -654,17 +672,6 @@ pub fn effective_annotation_scale_for( ) { return fallback; } - if style_annotative - && matches!( - entity, - EntityType::Text(_) - | EntityType::MText(_) - | EntityType::AttributeEntity(_) - | EntityType::AttributeDefinition(_) - ) - { - return fallback; - } // Unlike MTEXT / DIMENSION contexts, an MLEADER context carries its // already-scaled text height and overall scale factor. Keep the text @@ -1745,3 +1752,5 @@ pub fn is_annotative(doc: &CadDocument, entity: &EntityType) -> bool { _ => false, } } + +