From cfa2db38b3408c2c5ac8fb7c9392a772c3f48eb8 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 13:36:18 +0700 Subject: [PATCH] Contract stubs: craft-font-manager, craft-text, craft-pages --- crates/font-manager/src/axes.rs | 4 + crates/font-manager/src/axes/button.rs | 40 ++++ crates/font-manager/src/glyphs.rs | 136 +++++++++++- crates/font-manager/src/glyphs/stories.rs | 16 +- crates/font-manager/src/picker.rs | 112 +++++++++- crates/font-manager/src/picker/rank.rs | 3 +- crates/font-manager/src/picker/rows.rs | 16 +- crates/font-manager/tests/it/picker.rs | 2 +- crates/pages/src/ui/fixtures.rs | 3 +- crates/pages/src/ui/list.rs | 19 +- crates/pages/src/ui/marks.rs | 7 + crates/text/src/ui/character.rs | 239 +++++++++++++++++++++- crates/text/src/ui/character/paragraph.rs | 34 ++- crates/text/src/ui/find.rs | 3 +- crates/text/src/ui/find/dialog.rs | 104 +++++++++- crates/text/src/ui/ruler.rs | 48 +++-- crates/text/src/ui/ruler/geometry.rs | 14 +- crates/text/src/ui/ruler/items.rs | 59 +++--- crates/text/src/ui/ruler/paint.rs | 24 +-- crates/text/src/ui/ruler/run.rs | 36 ++-- crates/text/src/ui/spelling.rs | 22 +- crates/text/src/ui/style_panel.rs | 11 +- 22 files changed, 836 insertions(+), 116 deletions(-) create mode 100644 crates/font-manager/src/axes/button.rs diff --git a/crates/font-manager/src/axes.rs b/crates/font-manager/src/axes.rs index 6401367c6..a5949fe72 100644 --- a/crates/font-manager/src/axes.rs +++ b/crates/font-manager/src/axes.rs @@ -2,9 +2,13 @@ //! that edits them (Photoshop's Properties › Character axis sliders; FigCraft's axis panel). The data types //! and reading them from a font are always available; the sliders are on `ui`. +#[cfg(feature = "ui")] +mod button; #[cfg(feature = "ui")] mod sliders; #[cfg(feature = "ui")] +pub use button::AxesButton; +#[cfg(feature = "ui")] pub use sliders::*; use skrifa::string::StringId; diff --git a/crates/font-manager/src/axes/button.rs b/crates/font-manager/src/axes/button.rs new file mode 100644 index 000000000..3c9e67281 --- /dev/null +++ b/crates/font-manager/src/axes/button.rs @@ -0,0 +1,40 @@ +//! The axes behind one button: a `Button` that opens the axis sliders in a popover. + +use craft_ui::contract::{Bind, Pattern, Props}; +use craft_ui::runtime::env::Label; +use egui::Ui; + +use super::{AxisSlidersOutput, AxisValues, FontAxis, NamedInstance}; + +/// A `Button` with the label that opens an anchored `Popover` holding `AxisSliders` over the same props. The open +/// state is the button's own memory. The output is the sliders' (`edit`, `instance`), with the button's response. +#[must_use = "show the button with `show`"] +#[derive(Pattern, Props)] +#[allow(dead_code)] // P3(type-w3): ty.X21 +pub struct AxesButton<'a> { + label: Label, + axes: &'a [FontAxis], + values: Bind<'a, AxisValues>, + /// The named instances of the face, listed above the sliders. + #[prop] + instances: &'a [NamedInstance], + /// The style's weight, which an unset `wght` axis shows (an unset axis shows its default without it). + #[prop(quantity = "font weight, the `wght` coordinate")] + weight: Option, + /// Whether the style is italic: an unset `ital` axis then shows its maximum, once a weight is given. + #[prop] + italic: bool, +} + +impl<'a> AxesButton<'a> { + /// A button named `label` over the `axes` of a face, editing the coordinates `values`. + pub fn new(label: impl Into