PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge remote-tracking branch 'upstream/main' into type-recent-fonts
Reynold Hu77a67a5ea5fb
diff --cc crates/ui-egui/src/type_panels_ui.rsindex e2a5f5711,0ade5fc58..ae7f6265f--- a/crates/ui-egui/src/type_panels_ui.rs+++ b/crates/ui-egui/src/type_panels_ui.rs@@@ -510,9 -508,12 +510,12 @@@ fn options_editor(app: &mut PhotocraftA}/// Searchable family combo box.-fn family_picker(ui: &mut egui::Ui, salt: &str, current: &mut String, preview: photocraft_engine::prefs::FontPreview) -> bool {+fn family_picker(ui: &mut egui::Ui, salt: &str, current: &mut String, preview: photocraft_engine::prefs::FontPreview, recents: &[String]) -> bool {+ if !crate::type_tool::fonts_ready(ui, 140.0) {+ return false;+ }let mut shown = if current.is_empty() { photocraft_text::fonts::DEFAULT_FAMILY.to_string() } else { current.clone() };- let changed = crate::type_tool::family_picker_in(ui, salt, &mut shown, 140.0, &crate::type_tool::families(), preview);+ let changed = crate::type_tool::family_picker_in(ui, salt, &mut shown, 140.0, &crate::type_tool::families(), preview, recents);if changed {*current = shown;}diff --cc crates/ui-egui/src/type_tool.rsindex efa2931e7,18acd97d9..6b8368a1e--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@@ -1033,9 -1208,29 +1220,29 @@@ pub fn style_label(style: &str) -> Stristyle.split(' ').map(|w| crate::i18n::tr_ctx(crate::i18n::current(), "fontWeight", w)).collect::<Vec<_>>().join(" ")}+ /// Starts scanning the installed fonts on a background thread (desktop start-up), so choosing+ /// the Type tool doesn't stall the UI while they are read (#3021). Does nothing on the web.+ pub fn warm_fonts() {+ photocraft_text::warm_shared();+ }++ /// Whether the font database is ready. The installed fonts are scanned on a background thread+ /// from launch (`photocraft_text::warm_shared`); until that finishes, font menus draw this+ /// disabled "Loading fonts…" box `width` wide instead of blocking the UI, and a repaint picks the+ /// menus up once the scan is done.+ pub(crate) fn fonts_ready(ui: &mut egui::Ui, width: f32) -> bool {+ if photocraft_text::try_shared().is_some() {+ return true;+ }+ let label = tl!("Loading fonts…").to_string();+ ui.add_enabled_ui(false, |ui| crate::widgets::dropdown(ui, "fonts-loading", &mut label.clone(), &[(label.clone(), label.as_str())], width));+ ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));+ false+ }+/// Searchable font-family combo box.-fn font_picker(ui: &mut egui::Ui, current: &mut String, width: f32, preview: photocraft_engine::prefs::FontPreview) -> bool {- family_picker_in(ui, "type-font", current, width, &families(), preview)+fn font_picker(ui: &mut egui::Ui, current: &mut String, width: f32, preview: photocraft_engine::prefs::FontPreview, recents: &[String]) -> bool {+ family_picker_in(ui, "type-font", current, width, &families(), preview, recents)}/// Maximum height of the font menu.@@@ -1324,19 -1511,21 +1531,22 @@@ pub fn options_bar(app: &mut Photocraftapp.ui.status_error = true;}}- if font_picker(ui, &mut fam, 170.0, app.session.prefs().type_.font_preview, &app.ui.recent_fonts) {- app.note_recent_font(&fam);- app.ui.tool_options.type_font = fam.clone();- let st = styles(&fam);- style = if st.contains(&style) { style } else { st.first().cloned().unwrap_or_else(|| "Regular".into()) };- app.ui.tool_options.type_style = style.clone();- apply(app, ui.ctx(), json!({"font": fam}));- }- let opts: Vec<(String, String)> = styles(&fam).into_iter().map(|s| (s.clone(), style_label(&s))).collect();- let opts_ref: Vec<(String, &str)> = opts.iter().map(|(a, b)| (a.clone(), b.as_str())).collect();- if crate::widgets::dropdown(ui, "type-style", &mut style, &opts_ref, 110.0) {- app.ui.tool_options.type_style = style.clone();- apply(app, ui.ctx(), json!({"fontStyle": style}));+ // Font family and style menus (one placeholder in their place while the fonts load).+ if fonts_ready(ui, 170.0 + ui.spacing().item_spacing.x + 110.0) {- if font_picker(ui, &mut fam, 170.0, app.session.prefs().type_.font_preview) {++ if font_picker(ui, &mut fam, 170.0, app.session.prefs().type_.font_preview, &app.ui.recent_fonts) {++ app.note_recent_font(&fam);+ app.ui.tool_options.type_font = fam.clone();+ let st = styles(&fam);+ style = if st.contains(&style) { style } else { st.first().cloned().unwrap_or_else(|| "Regular".into()) };+ app.ui.tool_options.type_style = style.clone();+ apply(app, ui.ctx(), json!({"font": fam}));+ }+ let opts: Vec<(String, String)> = styles(&fam).into_iter().map(|s| (s.clone(), style_label(&s))).collect();+ let opts_ref: Vec<(String, &str)> = opts.iter().map(|(a, b)| (a.clone(), b.as_str())).collect();+ if crate::widgets::dropdown(ui, "type-style", &mut style, &opts_ref, 110.0) {+ app.ui.tool_options.type_style = style.clone();+ apply(app, ui.ctx(), json!({"fontStyle": style}));+ }}let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 22.0), egui::Sense::hover());crate::icons::paint(ui, r, "type", 13.0, t.icon);@@@ -1636,9 -1826,10 +1847,11 @@@ fn type_sections(app: &mut PhotocraftAplet full = ui.available_width();let w = field_width(full, 2, LABEL_W);let mut fam = c.font_family.clone();+ let mut ready = true;row(ui, &mut |ui| {- if font_picker(ui, &mut fam, full, app.session.prefs().type_.font_preview, &app.ui.recent_fonts) {+ ready = fonts_ready(ui, full);- if ready && font_picker(ui, &mut fam, full, app.session.prefs().type_.font_preview) {++ if ready && font_picker(ui, &mut fam, full, app.session.prefs().type_.font_preview, &app.ui.recent_fonts) {+ app.note_recent_font(&fam);app.ui.tool_options.type_font = fam.clone();apply(app, ui.ctx(), json!({"font": fam}));}diff --cc docs/scorecard.mdindex 1cffe7892,c6d67f8f9..5d7339a76--- a/docs/scorecard.md+++ b/docs/scorecard.md@@@ -7,11 -7,11 +7,11 @@@ Generated by `cargo xtask scorecard` fr| Area | Done | Partial | Missing | Key numbers ||---|---:|---:|---:|---|| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |- | [File compatibility](#file-compatibility) | 6 | 12 | 9 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |- | [Tools](#tools) | 25 | 16 | 2 | |- | [Workspace and UI](#workspace-and-ui) | 9 | 8 | 6 | settings that do nothing: 31 of 154 (target 0) |- | [Type](#type) | 1 | 4 | 4 | |- | [Automation](#automation) | 3 | 2 | 6 | 630 of 630 menu items live (100.0%) |+ | [File compatibility](#file-compatibility) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |+ | [Tools](#tools) | 27 | 14 | 2 | |-| [Workspace and UI](#workspace-and-ui) | 11 | 6 | 6 | settings that do nothing: 30 of 154 (target 0) |++| [Workspace and UI](#workspace-and-ui) | 11 | 6 | 6 | settings that do nothing: 29 of 154 (target 0) |+ | [Type](#type) | 4 | 2 | 3 | |+ | [Automation](#automation) | 3 | 2 | 6 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present || [Distribution](#distribution) | 5 | 4 | 2 | || [Open bugs](#open-bugs) | 29 | 2 | 1 | |@@@ -176,9 -176,9 +176,9 @@@ Corpus floors (`crates/io/tests/corpus.## Workspace and UI- **Settings that do nothing: 31 of 154** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.-**Settings that do nothing: 30 of 154** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.++**Settings that do nothing: 29 of 154** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.- Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.image_previews`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.-Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.++Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.| Id | Target | Status | Issue | Note ||---|---|---|---|---|