Filter the font menu by script, with the Indic scripts

The font pickers offer Latin, the nine Indic scripts, East Asian, Japanese and Thai in the toolbar's Script select (craft-libs#4514). Scorecard row TYPE-10996-2.
This commit is contained in:
ruchirguitar committed 2026-12-01 23:21:36 +05:30
1 parent 60cd87cd8e
commit 76c64f19e6
4 files changed
+51 -3

No files matched your search

@@ -233,3 +233,22 @@ fn hovering_a_font_adds_no_history_step_and_a_pick_adds_one() {
assert_eq!(layer_font(h.state()), "JetBrains Mono");
assert_eq!(history_len(h.state()), before + 1, "the pick is one history step");
}
/// The toolbar's Script select offers the Indic scripts (#10996); picking Devanagari narrows the family list and is
/// kept as the pickers' filter.
#[test]
fn the_family_list_filters_by_an_indic_script() {
let mut h = bar_harness(app_with_layer());
h.run_steps(4);
assert_eq!(h.state().ui.font_filters.script, None, "no script filter at first");
field(&h).click();
h.run();
let families = |h: &Harness<'static, Box<PhotocraftApp>>| h.query_all_by_role(Role::TreeItem).count();
let before = families(&h);
h.get_by_role_and_label(Role::ComboBox, "Script").click();
h.run();
h.get_by_label("Devanagari").click();
h.run();
assert_eq!(h.state().ui.font_filters.script, Some(craft::font_manager::picker::FontScript::Devanagari));
assert!(families(&h) < before, "the Latin-only families leave the list ({} of {before} left)", families(&h));
}
+23 -2
View File
@@ -1,4 +1,4 @@
use craft::font_manager::picker::{FontFilters, FontPickerSettings, FontPreviewSize};
use craft::font_manager::picker::{FontFilters, FontPickerSettings, FontPreviewSize, FontScript};
use craft::text::ui::character::FontPickerSource;
use craft::ui::contract::Bind;
use photocraft_engine::prefs::FontPreview;
@@ -95,6 +95,23 @@ pub(super) fn preview_text(app: &PhotocraftApp) -> Option<String> {
(!line.is_empty()).then_some(line)
}
/// The scripts the font pickers' script row offers: Latin, the Indic scripts, then the East Asian ones and Thai.
const PICKER_SCRIPTS: [FontScript; 13] = [
FontScript::Latin,
FontScript::Devanagari,
FontScript::Bengali,
FontScript::Gurmukhi,
FontScript::Gujarati,
FontScript::Odia,
FontScript::Tamil,
FontScript::Telugu,
FontScript::Kannada,
FontScript::Malayalam,
FontScript::EastAsian,
FontScript::Japanese,
FontScript::Thai,
];
/// The font picker's most recent families the settings may hold, whatever the preference says.
const MAX_RECENT_FONTS: usize = 50;
@@ -137,7 +154,11 @@ impl FontSourceState {
/// The picker's source over this state.
pub(crate) fn source(&mut self) -> FontPickerSource<'_> {
let catalog = photocraft_text::fonts::catalog();
let mut source = FontPickerSource::new(catalog).settings(Bind::bound(&mut self.settings)).filters(Bind::bound(&mut self.filters)).served(&self.served);
let mut source = FontPickerSource::new(catalog)
.settings(Bind::bound(&mut self.settings))
.filters(Bind::bound(&mut self.filters))
.served(&self.served)
.scripts(&PICKER_SCRIPTS);
if let Some(text) = self.preview_text.as_deref() {
source = source.preview_text(text);
}
+2 -1
View File
@@ -10,7 +10,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
| [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 |
| [Tools](#tools) | 36 | 9 | 0 | |
| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 204 (target 0) |
| [Type](#type) | 5 | 6 | 0 | |
| [Type](#type) | 6 | 6 | 0 | |
| [Automation](#automation) | 6 | 4 | 2 | 663 of 663 menu items live (100.0%) |
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |
| [Distribution](#distribution) | 5 | 5 | 1 | |
@@ -261,6 +261,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.
| 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) |
| TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) |
| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed |
| TYPE-10996-2 | Font menu filter by script, with the Indic scripts (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) beside Latin, East Asian, Japanese and Thai | done | [#10996](https://github.com/storytold/photocraft/issues/10996) | The font pickers (options bar, Character panel, Style Options) offer the script row (ui-egui type_tool fonts.rs); coverage is read from the cmap in craft-font-manager. Arabic and Hebrew are not offered yet |
| TYPE-10996-1 | Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) | partial | [#10996](https://github.com/storytold/photocraft/issues/10996) | CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. No Character panel control yet (needs the shared panel in craft-libs); Arabic and Persian digits are #6685; not saved in PSD |
## Automation
+7
View File
@@ -74,6 +74,13 @@ status = "partial"
issue = 218
note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with \"the path has too many anchor points\" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed"
[[item]]
id = "TYPE-10996-2"
target = "Font menu filter by script, with the Indic scripts (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) beside Latin, East Asian, Japanese and Thai"
status = "done"
issue = 10996
note = "The font pickers (options bar, Character panel, Style Options) offer the script row (ui-egui type_tool fonts.rs); coverage is read from the cmap in craft-font-manager. Arabic and Hebrew are not offered yet"
[[item]]
id = "TYPE-10996-1"
target = "Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam)"