feat(textstyle): full Text Style editor — big/TT font, fixed height, flags, annotative

Expands the Text Style manager beyond font/width/oblique: big-font and
TrueType font fields, fixed text height, Backward / Upside-down flags, and
an Annotative toggle (applied live). Bumps acadrust for the annotative
field.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-03 17:43:12 +03:00
1 parent 8b3d083789
commit 52850947d2
5 files changed
+131 -39

No files matched your search

+12
View File
@@ -305,6 +305,12 @@ pub(super) struct OpenCADStudio {
textstyle_width: String,
/// Edit buffer for oblique angle (degrees).
textstyle_oblique: String,
/// Edit buffer for fixed text height (0 = variable).
textstyle_height: String,
/// Edit buffer for big-font file name.
textstyle_bigfont: String,
/// Edit buffer for TrueType font name.
textstyle_ttf: String,
// ── Color Scheme ──────────────────────────────────────────────────────
active_theme: Theme,
@@ -880,6 +886,9 @@ pub enum Message {
TextStyleApply,
/// Select a font from the built-in font list.
TextStyleFontPick(String),
/// Flip a boolean flag on the selected text style (backward / upside_down /
/// vertical / annotative), applied immediately.
TextStyleToggle(&'static str),
// ── TableStyle Dialog ─────────────────────────────────────────────────
TableStyleDialogOpen,
#[allow(dead_code)]
@@ -1053,6 +1062,9 @@ impl OpenCADStudio {
textstyle_font: String::new(),
textstyle_width: "1.0".to_string(),
textstyle_oblique: "0.0".to_string(),
textstyle_height: "0.0".to_string(),
textstyle_bigfont: String::new(),
textstyle_ttf: String::new(),
// TableStyle dialog
tablestyle_selected: "Standard".to_string(),
// MLineStyle dialog
+33
View File
@@ -5634,10 +5634,31 @@ impl OpenCADStudio {
"font" => self.textstyle_font = value,
"width" => self.textstyle_width = value,
"oblique" => self.textstyle_oblique = value,
"height" => self.textstyle_height = value,
"bigfont" => self.textstyle_bigfont = value,
"ttf" => self.textstyle_ttf = value,
_ => {}
}
Task::none()
}
Message::TextStyleToggle(field) => {
let i = self.active_tab;
let name = self.textstyle_selected.clone();
if self.tabs[i].scene.document.text_styles.get(&name).is_some() {
self.push_undo_snapshot(i, "STYLE EDIT");
if let Some(s) = self.tabs[i].scene.document.text_styles.get_mut(&name) {
match field {
"backward" => s.flags.backward = !s.flags.backward,
"upside_down" => s.flags.upside_down = !s.flags.upside_down,
"annotative" => s.annotative = !s.annotative,
_ => {}
}
}
self.tabs[i].scene.bump_geometry();
self.tabs[i].dirty = true;
}
Task::none()
}
Message::TextStyleApply => {
let i = self.active_tab;
let name = self.textstyle_selected.clone();
@@ -5646,15 +5667,24 @@ impl OpenCADStudio {
let font = self.textstyle_font.clone();
let width_str = self.textstyle_width.clone();
let oblique_str = self.textstyle_oblique.clone();
let height_str = self.textstyle_height.clone();
let bigfont = self.textstyle_bigfont.clone();
let ttf = self.textstyle_ttf.clone();
if let Some(s) = self.tabs[i].scene.document.text_styles.get_mut(&name) {
s.font_file = font;
s.big_font_file = bigfont;
s.true_type_font = ttf;
if let Ok(w) = width_str.trim().parse::<f64>() {
s.width_factor = w;
}
if let Ok(a) = oblique_str.trim().parse::<f64>() {
s.oblique_angle = a.to_radians();
}
if let Ok(h) = height_str.trim().parse::<f64>() {
s.height = h.max(0.0);
}
}
self.tabs[i].scene.bump_geometry();
self.tabs[i].dirty = true;
}
Task::none()
@@ -6635,6 +6665,9 @@ impl OpenCADStudio {
self.textstyle_font = s.font_file.clone();
self.textstyle_width = format!("{:.4}", s.width_factor);
self.textstyle_oblique = format!("{:.2}", s.oblique_angle.to_degrees());
self.textstyle_height = format!("{:.4}", s.height);
self.textstyle_bigfont = s.big_font_file.clone();
self.textstyle_ttf = s.true_type_font.clone();
}
}
}
+19 -6
View File
@@ -65,13 +65,26 @@ impl OpenCADStudio {
.iter()
.map(|s| s.name.clone())
.collect();
return crate::ui::textstyle::view_window(
let (backward, upside_down, annotative) = tab
.scene
.document
.text_styles
.get(&self.textstyle_selected)
.map(|s| (s.flags.backward, s.flags.upside_down, s.annotative))
.unwrap_or((false, false, false));
return crate::ui::textstyle::view_window(crate::ui::textstyle::TextStyleView {
styles,
&self.textstyle_selected,
&self.textstyle_font,
&self.textstyle_width,
&self.textstyle_oblique,
);
selected: &self.textstyle_selected,
font_buf: &self.textstyle_font,
width_buf: &self.textstyle_width,
oblique_buf: &self.textstyle_oblique,
height_buf: &self.textstyle_height,
bigfont_buf: &self.textstyle_bigfont,
ttf_buf: &self.textstyle_ttf,
backward,
upside_down,
annotative,
});
}
if Some(window_id) == self.tablestyle_window {
use acadrust::objects::ObjectType;