fix(dimension): text colour (DIMCLRT) wins over the layer colour

The synthesised dimension text copied the dimension's ByLayer colour, and
its glyphs take their colour from that entity, so the layer colour showed.

Fixes #898

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-09-28 19:10:33 +03:00
1 parent 38fe2b0b08
commit e9e85010d8
1 file changed
+13 -1
+13 -1
View File
@@ -4331,8 +4331,20 @@ fn tessellate_dimension_inner(
}
}
if let Some(synth_text_entity) = dimension_text_entity(dim, dim_txt, style, document, dim_scale)
if let Some(mut synth_text_entity) =
dimension_text_entity(dim, dim_txt, style, document, dim_scale)
{
// The glyphs take their colour from the text entity itself, which
// copies the dimension's (usually ByLayer); an explicit DIMCLRT has to
// be on the entity or the layer colour wins. (#898)
let text_index = dim_color_index(
xd,
crate::entities::dim_override::DIMCLRT,
style.map(|s| s.dimclrt).unwrap_or(0),
);
if (1..=255).contains(&text_index) {
synth_text_entity.common_mut().color = AcadColor::from_index(text_index);
}
// Tolerance Text rendered separately so DIMTFAC scales its height
// and DIMTOLJ aligns it vertically against the primary text.
let tol_entity = dimension_tolerance_entity(dim, style, &synth_text_entity, dim_txt);