From 7783d124e5f2e788117fccb5cc35534d5c1734fb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 21 Dec 2019 17:08:01 -0800 Subject: [PATCH] font-loader: avoid panic on windows The upstream library panics for long family names --- src/font/locator/font_loader.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/font/locator/font_loader.rs b/src/font/locator/font_loader.rs index 6df4775df..bc9bde443 100644 --- a/src/font/locator/font_loader.rs +++ b/src/font/locator/font_loader.rs @@ -13,6 +13,15 @@ impl FontLocator for FontLoaderFontLocator { ) -> anyhow::Result> { let mut fonts = Vec::new(); for font_attr in fonts_selection { + if cfg!(windows) && font_attr.family.len() > 31 { + // Avoid a super painful panic in the upstream library: + // https://github.com/MSleepyPanda/rust-font-loader/blob/2b264974fe080955d341ce8a163035bdce24ff2f/src/win32.rs#L87 + log::error!( + "font-loader would panic for font family `{}`", + font_attr.family + ); + continue; + } let mut font_props = system_fonts::FontPropertyBuilder::new() .family(&font_attr.family) .monospace();