fix panic handling (probably) and tweek font discovery

macos-click-through
Keith Simmons 5 years ago
parent d0941cef2e
commit 934d63b278

@ -39,8 +39,8 @@ fn build_collection_by_font_name(font_name: Option<&str>) -> FontCollection {
let mut collection = FontCollection::new();
if let Some(font_name) = font_name {
if let Ok(custom) = source.select_family_by_name(font_name) {
let font = custom.fonts()[0].load().unwrap();
if let Ok(custom) = source.select_best_match(&[FamilyName::Title(font_name.to_string())], &Properties::new()) {
let font = custom.load().unwrap();
collection.add_family(FontFamily::new_from_font(font));
}
}

@ -171,14 +171,12 @@ pub fn ui_loop() {
let frame_start = Instant::now();
if REDRAW_SCHEDULER.should_draw() {
if let Err(err) = panic::catch_unwind(|| {
skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| {
if renderer.draw(canvas, coordinate_system_helper) {
handle_new_grid_size(window.inner_size(), &renderer)
}
}).ok();
if let Err(e) = skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| {
if renderer.draw(canvas, coordinate_system_helper) {
handle_new_grid_size(window.inner_size(), &renderer)
}
}) {
println!("Render failed. Closing app");
println!("Render failed. Closing");
*control_flow = ControlFlow::Exit;
return;
}

Loading…
Cancel
Save