DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Text: Bold and Italic link the document's own fonts
aiongge13dee07285e
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rsindex 6e572a98a..9b9f73ce8 100644--- a/crates/engine/src/cmd/file.rs+++ b/crates/engine/src/cmd/file.rs@@ -887,4 +887,24 @@ mod document_fonts_tests {assert!(glyph_faces(&s).iter().all(|(_, f)| f.family == FAMILY));let _ = std::fs::remove_dir_all(&dir);}++ #[test]+ fn bold_and_italic_link_the_document_fonts_styles() {+ const FAMILY: &str = "DocFont Linked";+ let dir = temp_dir("linked");+ std::fs::write(dir.join(DOCUMENT_FONTS_FOLDER).join("linked.ttf"), font_with(FAMILY, &['H', 'e', 'l', 'o']).unwrap()).unwrap();+ let path = dir.join("Linked.designcraft");+ write_document(&path, FAMILY);++ let mut s = Session::new();+ open(&mut s, &path);+ let sid = *s.doc().unwrap().doc.stories.keys().next().unwrap();+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ // The family is the document's alone: its Regular is the style without bold or italic.+ let r = s.execute("type.bold", &json!({"on": false})).unwrap();+ assert_eq!(r["fontStyle"], "Regular", "{r}");+ let r = s.execute("type.italic", &json!({"on": false})).unwrap();+ assert_eq!(r["fontStyle"], "Regular", "{r}");+ let _ = std::fs::remove_dir_all(&dir);+ }}diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex 3d5cd0223..062d74b20 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -1289,8 +1289,7 @@ pub fn character_panel(app: &mut DesignApp, ui: &mut egui::Ui) {});ui.horizontal(|ui| {// Bold and Italic pick the family's own styles (style linking).- let (weight, italic) =- designcraft_fonts::FontDb::global().traits_of(c["fontFamily"].as_str().unwrap_or_default(), c["fontStyle"].as_str().unwrap_or_default());+ let (weight, italic) = super::fonts(app).traits_of(c["fontFamily"].as_str().unwrap_or_default(), c["fontStyle"].as_str().unwrap_or_default());let tip = |app: &DesignApp, name: &str, id: &str| {let name = crate::i18n::tr(&app.ui.language, name);match crate::menus::shortcut_of(app, id) {