VectorCraft: An open-source, vector art tool written by scratch in pure Rust
G4: Properties panel shows Variable Font axes for selected type
nrq6993-a11y12f7d41c38a2
diff --git a/crates/ui-egui/src/panels/character.rs b/crates/ui-egui/src/panels/character.rsindex c7252993f..7838967da 100644--- a/crates/ui-egui/src/panels/character.rs+++ b/crates/ui-egui/src/panels/character.rs@@ -535,7 +535,7 @@ pub(crate) fn font_pickers(app: &mut VectorcraftApp, ui: &mut Ui, s: &CharStyle,/// The Variable Font button, `width` wide, shown when the font of style `s` is a variable font: it/// opens the font's axis sliders ([`axis_sliders`]).-fn variable_font(app: &mut VectorcraftApp, ui: &mut Ui, s: &CharStyle, width: f32) {+pub(crate) fn variable_font(app: &mut VectorcraftApp, ui: &mut Ui, s: &CharStyle, width: f32) {let Some(face) = vectorcraft_text::FontDb::global().face_version(&s.font_family, &s.font_style, s.font_version.as_deref()) else { return };if face.axes().iter().all(|a| a.hidden) {return;diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex dc92a4b7e..84fa1f9ae 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -561,6 +561,7 @@ pub fn type_sections(app: &mut VectorcraftApp, ui: &mut Ui) {// The font, Font Size, Leading, Kerning and Tracking as in the Character panel.let w = ui.available_width();super::character::font_pickers(app, ui, &s, ("font", "font-style"), (w - 4.0, w - 4.0));+ super::character::variable_font(app, ui, &s, w - 4.0);super::character::metrics_grid(app, ui, "props-char", &s, w, false);section_header(ui, tl!("Paragraph"));// As in the Paragraph panel: the seven alignments and Hyphenate (#775); the rest is there.@@ -813,6 +814,22 @@ mod tests {assert!(hyphenate(&app));}+ /// Variable fonts get the same Variable Font button in Properties as in the Character panel.+ #[test]+ fn properties_variable_font_button_for_variable_type() {+ use vectorcraft_text::test_fonts::{TWO_AXIS_FAMILY, two_axis_font};+ vectorcraft_text::FontDb::global().add_font(two_axis_font().unwrap());+ let mut app = VectorcraftApp::new(Session::new(), Default::default());+ app.run("file.new", json!({"width": 300, "height": 200})).unwrap();+ let plain = app.run("text.create", json!({"x": 20, "y": 50, "text": "Static"})).unwrap()["id"].clone();+ let id = app.run("text.create", json!({"x": 20, "y": 120, "text": "lIn", "font": TWO_AXIS_FAMILY})).unwrap()["id"].clone();+ let ctx = egui::Context::default();+ app.run("select.set", json!({"ids": [plain]})).unwrap();+ assert!(!frame(&mut app, &ctx, vec![]).iter().any(|(t, _)| t == "Variable Font"));+ app.run("select.set", json!({"ids": [id]})).unwrap();+ assert!(frame(&mut app, &ctx, vec![]).iter().any(|(t, _)| t == "Variable Font"));+ }+#[test]fn edit_artboards_adds_artboards_and_exits() {let mut app = VectorcraftApp::new(Session::new(), Default::default());