1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

font-loader: avoid panic on windows

The upstream library panics for long family names
This commit is contained in:
Wez Furlong 2019-12-21 17:08:01 -08:00
parent 662227a725
commit 7783d124e5

View File

@ -13,6 +13,15 @@ impl FontLocator for FontLoaderFontLocator {
) -> anyhow::Result<Vec<FontDataHandle>> {
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();