From 93e3931753ea8111dc6b3f35aa56bfa572b502b2 Mon Sep 17 00:00:00 2001 From: astar76 Date: Fri, 27 Nov 2026 15:33:14 -0600 Subject: [PATCH 1/2] Window reopened from the tray draws its fonts and icons again A new window's painter starts empty while egui thinks the font atlas and icon textures are uploaded. Each reopen now drops the icon textures and installs fonts with new definitions, so both are sent again. Checked with tools/tray-check (two reopens, screenshots). Co-Authored-By: Claude Opus 5.5 --- crates/app/src/app.rs | 7 +++++++ crates/app/src/fonts.rs | 9 +++++++++ crates/app/src/icons.rs | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs index 7e278ad..d92c53b 100644 --- a/crates/app/src/app.rs +++ b/crates/app/src/app.rs @@ -569,8 +569,15 @@ fn open(engine: bool, show: fn(&mut App, &mut Ui), mut args: Vec) -> Exi app.shell = Some(shell); } let mut code = ExitCode::SUCCESS; + let mut opened = 0; loop { if window { + if opened > 0 { + // The new window's painter starts empty: fonts and icons go up again. + crate::icons::forget(); + crate::fonts::reload(&ctx, opened); + } + opened += 1; let this = &mut app; let make: eframe::AppCreator<'_> = Box::new(move |_| Ok(Box::new(Window { app: this, show }))); if let Err(e) = eframe::run_native_ext(APP_ID, options(&paths), Some(ctx.clone()), make) { diff --git a/crates/app/src/fonts.rs b/crates/app/src/fonts.rs index d01f572..2b61911 100644 --- a/crates/app/src/fonts.rs +++ b/crates/app/src/fonts.rs @@ -10,6 +10,12 @@ const SEMI: &str = "rubik-600"; static RUBIK: &[u8] = include_bytes!("../../../assets/Rubik.ttf"); pub fn install(ctx: &egui::Context) { + reload(ctx, 0); +} + +/// A new window has a new painter that holds no font atlas: other definitions (an unused family named after the +/// window count) make egui build and send the whole atlas again. +pub fn reload(ctx: &egui::Context, window: u32) { let mut defs = FontDefinitions::default(); let fallback = defs.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); for (key, family, weight) in [ @@ -22,6 +28,9 @@ pub fn install(ctx: &egui::Context) { let names = std::iter::once(key.to_string()).chain(fallback.iter().cloned()).collect(); defs.families.insert(family, names); } + if window > 0 { + defs.families.insert(FontFamily::Name(format!("window-{window}").into()), vec!["rubik".into()]); + } ctx.set_fonts(defs); ctx.all_styles_mut(|s| { s.text_styles = [ diff --git a/crates/app/src/icons.rs b/crates/app/src/icons.rs index d47ab34..866a88f 100644 --- a/crates/app/src/icons.rs +++ b/crates/app/src/icons.rs @@ -14,6 +14,11 @@ thread_local! { static CACHE: RefCell> = RefCell::new(HashMap::new()); } +/// A new window's painter has none of the icon textures: drop them so they are made and sent again. +pub fn forget() { + CACHE.with_borrow_mut(HashMap::clear); +} + /// Premultiplied pixels of an SVG, `px` wide and high. fn render(svg: &str, px: u32) -> Option { let tree = usvg::Tree::from_str(svg, &usvg::Options::default()).ok()?; From 853153fcc8fd62ba9998d9743cee4568fc06662d Mon Sep 17 00:00:00 2001 From: astar76 Date: Fri, 27 Nov 2026 15:33:23 -0600 Subject: [PATCH 2/2] Package sums for the reopen fix build Co-Authored-By: Claude Opus 5.5 --- packaging/arch/.SRCINFO | 2 +- packaging/arch/PKGBUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/arch/.SRCINFO b/packaging/arch/.SRCINFO index 06bed4d..16c81d0 100644 --- a/packaging/arch/.SRCINFO +++ b/packaging/arch/.SRCINFO @@ -24,6 +24,6 @@ pkgbase = medlar-bin options = !strip options = !debug source = Medlar-0.1.1-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Medlar/releases/download/v0.1.1/Medlar-0.1.1-Linux-x86_64.tar.gz - sha256sums = c585f3bb2646a9115b6850533afa362b70863e676e0b2e98ceb9ca459e22671b + sha256sums = 3be0a4ec1b953819d8b84b0563fcacddcee3c93a3c4ba40d364a09c590c7f7a6 pkgname = medlar-bin diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index c412791..b4186d4 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -15,7 +15,7 @@ conflicts=('medlar') options=('!strip' '!debug') # MEDLAR_TARBALL points at a local copy (offline build); default is the release download. source=("Medlar-$pkgver-Linux-x86_64.tar.gz::${MEDLAR_TARBALL:-$url/releases/download/v$pkgver/Medlar-$pkgver-Linux-x86_64.tar.gz}") -sha256sums=('c585f3bb2646a9115b6850533afa362b70863e676e0b2e98ceb9ca459e22671b') +sha256sums=('3be0a4ec1b953819d8b84b0563fcacddcee3c93a3c4ba40d364a09c590c7f7a6') package() { cd "$srcdir/medlar-$pkgver"