Skip to content

Commit

Permalink
feat(text): don't crash if url can't be fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Sep 27, 2023
1 parent a42257d commit 8b328c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion crates/text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ impl AsyncAssetKey<Arc<FontArc>> for FontDef {
};
Arc::new(FontArc::try_from_slice(font).unwrap())
}
FontFamily::Custom(url) => FontFromUrl(url.clone()).get(&assets).await.unwrap(),
FontFamily::Custom(url) => match FontFromUrl(url.clone()).get(&assets).await {
Ok(font) => font,
Err(err) => {
log::error!("Failed to fetch font at {url}: {err}; using fallback font");
FontDef(FontFamily::Default, self.1).get(&assets).await
}
},
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions web/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8b328c8

Please sign in to comment.