Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Character panel: OpenType feature buttons (TYPE-218-5, #3752) (#3757)

David Mann4736a4bcbea5
diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs
index d7015a37a..e1e3573e0 100644
--- a/crates/ui-egui/src/type_tool.rs
+++ b/crates/ui-egui/src/type_tool.rs
@@ -1783,6 +1783,102 @@ fn toggle_cell(ui: &mut egui::Ui, w: f32, on: bool, tip: &str, paint: impl FnOnc
resp.on_hover_text(tl!(&tip)).clicked()
}
+/// The Character panel's OpenType buttons, in Photoshop's order: (feature tag, command id,
+/// tooltip). The tooltips are the Type › OpenType menu labels.
+pub(crate) const OPENTYPE_BUTTONS: [(&str, &str, &str); 8] = [
+ ("liga", "type.openType.standardLigatures", "Standard Ligatures"),
+ ("calt", "type.openType.contextualAlternates", "Contextual Alternates"),
+ ("dlig", "type.openType.discretionaryLigatures", "Discretionary Ligatures"),
+ ("swsh", "type.openType.swash", "Swash"),
+ ("salt", "type.openType.stylisticAlternates", "Stylistic Alternates"),
+ ("titl", "type.openType.titlingAlternates", "Titling Alternates"),
+ ("ordn", "type.openType.ordinals", "Ordinals"),
+ ("frac", "type.openType.fractions", "Fractions"),
+];
+
+/// Photoshop's OpenType button row: each shows pressed while its feature is on at the type
+/// target (the selection start, else the layer) and toggles it through the Type › OpenType
+/// command, on the same scope as the other Character controls.
+fn opentype_row(app: &mut PhotocraftApp, ui: &mut egui::Ui, c: &photocraft_doc::text::CharStyle, full: f32) {
+ let cw = cell_width(full, OPENTYPE_BUTTONS.len());
+ let mut clicked = None;
+ ui.horizontal(|ui| {
+ ui.spacing_mut().item_spacing.x = 2.0;
+ for (tag, id, tip) in OPENTYPE_BUTTONS {
+ let on = photocraft_engine::type_extra_cmds::feature_on(c, tag);
+ if toggle_cell(ui, cw, on, tip, |ui, r, col| opentype_glyph(ui.painter(), r, tag, col)) {
+ clicked = Some((id, on));
+ }
+ }
+ });
+ if let Some((id, on)) = clicked {
+ toggle_opentype(app, id, on);
+ }
+}
+
+/// Runs an OpenType toggle command on the Character panel's scope: the edited layer's selected
+/// characters (or its whole text) while typing, else every selected type layer. The new state
+/// is explicit, so it follows the button the user saw rather than the layer's first run.
+pub(crate) fn toggle_opentype(app: &mut PhotocraftApp, id: &str, shown_on: bool) {
+ let Some(mut p) = formatting_params(app) else { return };
+ p["on"] = json!(!shown_on);
+ let _ = app.run(id, p);
+}
+
+/// Small glyph labels for the OpenType buttons (drawn here, no Adobe artwork): fi, st, ct with
+/// a ligature arc, a swash A, aa, T, 1st and ½.
+fn opentype_glyph(p: &egui::Painter, r: egui::Rect, tag: &str, col: Color32) {
+ let font = egui::FontId::proportional(13.0);
+ let centred = |s: &str, font: egui::FontId| {
+ let g = p.layout_no_wrap(s.to_string(), font, col);
+ let pos = r.center() - g.size() / 2.0;
+ let gr = egui::Rect::from_min_size(pos, g.size());
+ p.galley(pos, g, col);
+ gr
+ };
+ match tag {
+ "liga" => {
+ centred("fi", font);
+ }
+ "calt" => {
+ centred("st", font);
+ }
+ "dlig" => {
+ let gr = centred("ct", font);
+ // The ligature's connecting arc from the c over to the t.
+ let a = egui::pos2(gr.left() + gr.width() * 0.3, gr.top() + gr.height() * 0.42);
+ let b = egui::pos2(gr.right() - gr.width() * 0.2, gr.top() + 4.0);
+ let mid = egui::pos2((a.x + b.x) / 2.0, gr.top() + 1.5);
+ p.line_segment([a, mid], Stroke::new(1.0, col));
+ p.line_segment([mid, b], Stroke::new(1.0, col));
+ }
+ "swsh" => {
+ let gr = centred("A", crate::theme::semibold(13.0));
+ // A swash tail sweeping out under the letter.
+ let y = gr.bottom() - 3.0;
+ p.line_segment([egui::pos2(gr.left() - 3.0, y + 1.5), egui::pos2(gr.right() + 2.0, y - 0.5)], Stroke::new(1.0, col));
+ }
+ "salt" => {
+ centred("aa", font);
+ }
+ "titl" => {
+ centred("T", crate::theme::semibold(13.0));
+ }
+ "ordn" => {
+ let one = p.layout_no_wrap("1".into(), font, col);
+ let st = p.layout_no_wrap("st".into(), egui::FontId::proportional(9.0), col);
+ let left = r.center().x - (one.size().x + st.size().x) / 2.0;
+ let top = r.center().y - one.size().y / 2.0;
+ let st_x = left + one.size().x;
+ p.galley(egui::pos2(left, top), one, col);
+ p.galley(egui::pos2(st_x, top - 1.0), st, col);
+ }
+ _ => {
+ centred("½", font);
+ }
+ }
+}
+
/// Width of each of `n` equal cells filling `avail` with 2 pt gaps.
fn cell_width(avail: f32, n: usize) -> f32 {
let n = n.max(1) as f32;
@@ -1957,6 +2053,8 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
}
});
ui.add_space(ROW_GAP);
+ opentype_row(app, ui, &c, full);
+ ui.add_space(ROW_GAP);
}
if paragraph && section(ui, "paragraph", tl!("Paragraph")) {
use photocraft_doc::text::TextAlign as A;
diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rs
index 46d763e5b..a1c6415b9 100644
--- a/crates/ui-egui/src/type_tool_tests.rs
+++ b/crates/ui-egui/src/type_tool_tests.rs
@@ -1455,6 +1455,51 @@ mod multi_layer_formatting {
assert_eq!(text(&app, ids[0]).antialias, AntiAlias::Sharp);
}
+ /// The Character panel's OpenType buttons (TYPE-218-5, #3752): Photoshop's eight, in its
+ /// order; each shows pressed while its feature is on and toggles it on the selected type
+ /// layers, or on the selected characters while typing.
+ #[test]
+ fn character_panel_opentype_buttons_toggle_and_show_the_feature() {
+ use egui::accesskit::Toggled;
+ use egui_kittest::kittest::NodeT;
+ use photocraft_engine::type_extra_cmds::feature_on;
+ let (app, ids) = fixture();
+ let untouched = style(&app, ids[2], 0);
+ let mut h = controls(app, true);
+ let shown = |h: &Harness<'static, PhotocraftApp>, label: &str| h.get_by_label(label).accesskit_node().toggled();
+ let order: Vec<String> = h
+ .get_all_by_role(Role::Button)
+ .filter_map(|n| n.accesskit_node().label())
+ .filter(|l| super::super::OPENTYPE_BUTTONS.iter().any(|(_, _, tip)| tip == l))
+ .collect();
+ let expected: Vec<&str> = super::super::OPENTYPE_BUTTONS.iter().map(|(_, _, tip)| *tip).collect();
+ assert_eq!(order, expected, "every OpenType button, in Photoshop's order");
+ assert_eq!(shown(&h, "Standard Ligatures"), Some(Toggled::True), "ligatures are on by default");
+ assert_eq!(shown(&h, "Fractions"), Some(Toggled::False));
+ h.get_by_label("Fractions").click();
+ h.run();
+ for id in &ids[..2] {
+ assert!(feature_on(&style(h.state(), *id, 0), "frac"), "selected layers get the feature");
+ }
+ assert_eq!(style(h.state(), ids[2], 0), untouched, "an unselected layer is untouched");
+ h.run();
+ assert_eq!(shown(&h, "Fractions"), Some(Toggled::True), "the button shows the feature on");
+ h.get_by_label("Standard Ligatures").click();
+ h.run();
+ h.run();
+ assert!(!style(h.state(), ids[0], 0).ligatures && !style(h.state(), ids[1], 0).ligatures);
+ assert_eq!(shown(&h, "Standard Ligatures"), Some(Toggled::False));
+ // While typing, only the selected characters (1..3) change.
+ editing(h.state_mut(), ids[0]);
+ h.run();
+ h.get_by_label("Swash").click();
+ h.run();
+ let swash = |h: &Harness<'static, PhotocraftApp>, ci| feature_on(&style(h.state(), ids[0], ci), "swsh");
+ assert!(!swash(&h, 0) && swash(&h, 1) && swash(&h, 2) && !swash(&h, 3));
+ h.run();
+ assert_eq!(shown(&h, "Swash"), Some(Toggled::True), "shown at the selection start");
+ }
+
/// Type › Anti-Alias and Type › Orientation check the edited (else selected) layer's value.
#[test]
fn type_menu_checks_the_current_anti_alias_and_orientation() {
diff --git a/docs/gaps.md b/docs/gaps.md
index 7937e6664..2ceba0995 100644
--- a/docs/gaps.md
+++ b/docs/gaps.md
@@ -1,6 +1,6 @@
# Where PhotoCraft falls short of Photoshop
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (G8: triple-, quadruple- and five-click type selection landed, TYPE-218-8 done; Czech UI localization evidence added to G13; G14: D5100 crop and Camera Raw tuning validation) · **Target:** Adobe Photoshop 2026
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (G8: Character panel OpenType buttons landed, TYPE-218-5 stays partial; G8: triple-, quadruple- and five-click type selection landed, TYPE-218-8 done; Czech UI localization evidence added to G13; G14: D5100 crop and Camera Raw tuning validation) · **Target:** Adobe Photoshop 2026
Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact
on the way to beta. This is the work list agents pick from: take the highest-ranked entry that
@@ -76,8 +76,9 @@ what an agent can't finish alone.
### G8. Type depth
- **Missing:** type on a path (TYPE-218-1), paragraph direction UI (TYPE-218-2), complex-script
- fallback fonts and golden tests (TYPE-218-3), OpenType panel UI (TYPE-218-5), live Warp Text
- preview (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type
+ fallback fonts and golden tests (TYPE-218-3), OpenType Numerals and Stylistic Sets submenus
+ (TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), live Warp Text preview
+ (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type
(TYPE-218-9), text free transform (#2630). Done since the re-measure: manual and optical kerning
with PSD round trip (TYPE-218-6, #206), variable-font axes (TYPE-218-4, #2985).
- **Evidence:** scorecard Type: 3 done, 2 partial, 4 missing. 2026-10-11: 2/3/4/5 clicks select
@@ -227,6 +228,7 @@ what an agent can't finish alone.
| 2026-10-11 | minor | D5100 image area and Camera Raw tuning validation; G14 remains open |
| 2026-10-11 | minor | G13: Czech dynamic UI text localized; engine messages and native review remain open |
| 2026-10-11 | minor | G8: triple/quadruple/five-click type selection done (TYPE-218-8, #3493); Type evidence recounted |
+| 2026-10-11 | minor | G8: Character panel OpenType buttons landed (TYPE-218-5, #3752); Numerals and Stylistic Sets submenus still missing |
| 2026-10-10 | minor | G2: recorded Tilt-Shift computation/filtered-proxy measurements and limits; gap and estimate remain open |
| 2026-10-10 | minor | Checked against the alpha gate (no alpha blockers); #2374 marked closed |
| 2026-10-10 | major | First version, from the full re-measure against Photoshop 2026 27.11.0 and the open issues |
diff --git a/docs/scorecard.md b/docs/scorecard.md
index 5b6275f0e..8e8aa3080 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -214,7 +214,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w
| TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | missing | [#218](https://github.com/storytold/photocraft/issues/218) | Engine has TextDirection (text.rs:155); no UI |
| TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Thai is covered: THAI_FAMILIES (fonts.rs) lists the Windows, macOS and Linux families and thai_in_latin_font_falls_back_to_installed_thai_font checks a sample with above and below marks (#1909); Arabic and Hebrew fall back too. Khmer and Indic have no fallback list, and there are no per-script golden shaping tests (only a bidi test) |
| TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet |
-| TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs:512); no panel buttons or submenus |
+| TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks |
| TYPE-218-6 | Manual pair kerning (Alt+arrows), optical kerning rendered, both round-trip PSD (#206) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Alt+Left/Right at a collapsed caret kerns the pair (type_tool.rs kern_pair, 20 per step and 100 with Cmd; type_tool_alt_arrows_kern_the_pair). Optical kerning is computed from the glyph outlines in text/src/optical.rs and applied by layout.rs when the run's mode is Optical (optical_matches_photoshop, optical_kerning_tightens_open_pairs). Both modes and manual values round-trip through PSD (io/tests/psd_kerning.rs; the optical mode travels in Txt2, txt2_carries_optical_kerning) |
| TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 |
| TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) |
diff --git a/scorecard/type.toml b/scorecard/type.toml
index ea1b35d6b..81064ce8d 100644
--- a/scorecard/type.toml
+++ b/scorecard/type.toml
@@ -37,7 +37,7 @@ id = "TYPE-218-5"
target = "OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus"
status = "partial"
issue = 218
-note = "Type > OpenType toggles (type_extra_cmds.rs:512); no panel buttons or submenus"
+note = "Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks"
[[item]]
id = "TYPE-218-6"