mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 17:56:50 -06:00
G4: Properties panel shows Variable Font axes for selected type
Reuse the Character panel's Variable Font popover in Properties so axis sliders are available without opening Character. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
bflatastic
co-authored by
Cursor
parent
85163a7c82
commit
12f7d41c38
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user