From 92e32243ebc6e7327b92a1cb9d48e2a1b5a0f170 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 14 Jun 2026 01:15:52 +0300 Subject: [PATCH] fix(style): new text/mtext/dimension use the current style (#92) New annotation entities were created at the entity "Standard" default instead of the document's current style, so making a style current had no effect on creation. - Text / MText: seed the new entity (and the MText editor preview) from header.current_text_style_name. - Dimension: commit_entity_handle fills the new dimension's style_name from header.current_dimstyle_name, covering every dimension command centrally. Applied only when the entity is still at its default so an explicitly styled entity is preserved. MLeader and Table styles need their style tables modelled first and are left for follow-up. Co-Authored-By: Claude Opus 4.8 --- src/app/mtext_editor.rs | 12 ++++++++++++ src/app/properties.rs | 17 +++++++++++++++++ src/app/text_inline.rs | 13 ++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/app/mtext_editor.rs b/src/app/mtext_editor.rs index d7ee0d8c6..16ae076f9 100644 --- a/src/app/mtext_editor.rs +++ b/src/app/mtext_editor.rs @@ -364,6 +364,18 @@ impl super::OpenCADStudio { } _ => {} } + } else { + // New MText inherits the document's current text style (STYLE), + // not the "Standard" default. See #92. + let cur_style = self.tabs[self.active_tab] + .scene + .document + .header + .current_text_style_name + .clone(); + if !cur_style.trim().is_empty() { + state.style = cur_style; + } } self.mtext_editor = Some(state); self.rebuild_mtext_preview(); diff --git a/src/app/properties.rs b/src/app/properties.rs index 8eef3bde2..064a496f0 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -541,6 +541,23 @@ impl OpenCADStudio { entity.common_mut().linetype_scale = celtscale; } + // A new dimension inherits the document's current dimension style + // (DIMSTYLE) instead of staying at the entity "Standard" default. Only + // fill in when still at the default so an explicitly-styled dimension + // is preserved. See #92. + if let acadrust::EntityType::Dimension(ref mut d) = entity { + let cur = self.tabs[i] + .scene + .document + .header + .current_dimstyle_name + .clone(); + let s = d.base().style_name.clone(); + if (s.is_empty() || s.eq_ignore_ascii_case("Standard")) && !cur.is_empty() { + d.base_mut().style_name = cur; + } + } + // Commands pick points in local space (camera coordinates with world_offset // already subtracted). Re-add world_offset so the entity lands at the correct // DXF coordinate. Skip for paper-space entities (they use sheet mm coords). diff --git a/src/app/text_inline.rs b/src/app/text_inline.rs index 5420f738e..949a0df2c 100644 --- a/src/app/text_inline.rs +++ b/src/app/text_inline.rs @@ -190,11 +190,22 @@ impl super::OpenCADStudio { self.tabs[i].scene.bump_geometry(); self.tabs[i].dirty = true; } else { - let t = Text::with_value( + let mut t = Text::with_value( &ed.value, Vector3::new(ed.pos.x as f64, ed.pos.y as f64, ed.pos.z as f64), ) .with_height(ed.height); + // New text inherits the document's current text style (STYLE), not + // the entity default. See #92. + let cur_style = self.tabs[i] + .scene + .document + .header + .current_text_style_name + .clone(); + if !cur_style.is_empty() { + t.style = cur_style; + } self.push_undo_snapshot(i, "TEXT"); self.commit_entity(EntityType::Text(t)); self.tabs[i].dirty = true;