diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 97e0124dd6..b4c07d5b03 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -676,6 +676,21 @@ impl PdfCraftApp { self.views.iter().any(|v| v.render_pending()) } + /// `true` until the installed fonts have been found and catalogued, which the Format text + /// font field starts when it first shows. The field is shut ("Loading fonts…") while the + /// catalogue is built, and a list opened before that closes when it arrives, so a headless + /// test waits for this to be `false` before it opens the field. + pub fn installed_fonts_pending(&self) -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + self.document_fonts.as_ref().is_none_or(|fonts| !fonts.catalog.is_ready()) + } + #[cfg(target_arch = "wasm32")] + { + false + } + } + /// Check whether a tool group is pinned to Home. pub fn is_tool_pinned(&self, id: &str) -> bool { self.pinned_tools.iter().any(|t| t == id) diff --git a/crates/ui-egui/tests/it/edit.rs b/crates/ui-egui/tests/it/edit.rs index e6b9dd910b..e7ae037ec3 100644 --- a/crates/ui-egui/tests/it/edit.rs +++ b/crates/ui-egui/tests/it/edit.rs @@ -191,6 +191,10 @@ fn format_text_font_picker_applies_document_font_to_added_text() { assert!(h.execute("edit.edit_text")); h.state_mut().views[0].session.content.selected = Some((0, 0)); h.run_steps(4); + // The font field is shut ("Loading fonts…") while the installed fonts are catalogued on a + // worker thread, and a list opened before then closes when the catalogue arrives. A runner + // that reads many fonts (Windows) is still at it after these frames. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); font_node.click(); diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index aa290c7678..fab1699e6d 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -10578,6 +10578,9 @@ fn format_panel_shows_selection_size_and_updates_after_font_applied() { let size_node = h.get_by_role_and_label(Role::SpinButton, "Font size"); assert_eq!(size_node.value().as_deref(), Some("12"), "size text input value is 12"); + // The font field reads "Loading fonts…" and is shut while the installed fonts are catalogued + // on a worker thread; a runner that reads many fonts (Windows) is still at it after the frames above. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); assert_eq!(font_node.value().as_deref(), Some("Helvetica"), "initial font is Helvetica");