fix(annotative): scale text by its own annotativeness, not its style's

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 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5 committed 2026-08-08 02:45:59 +03:00
1 parent 2ea3bca093
commit db43c21d55
1 file changed
+21 -12
+21 -12
View File
@@ -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,
}
}