From e9e85010d8e7262ff045e68c6c8715c3a996c92a Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 28 Sep 2026 19:10:33 +0300 Subject: [PATCH] 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 --- src/entities/dimension.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/entities/dimension.rs b/src/entities/dimension.rs index c1d50ca53..f20f3506b 100644 --- a/src/entities/dimension.rs +++ b/src/entities/dimension.rs @@ -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);