From e52dcc0c6dc3b2d258a53c79758e7e8269672aa1 Mon Sep 17 00:00:00 2001 From: Ragnar Groot Koerkamp Date: Tue, 25 Jul 2023 22:04:37 +0200 Subject: [PATCH] SDL: look in multiple paths for opensans-regular.ttf Fix #18 --- pa-vis/src/sdl.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pa-vis/src/sdl.rs b/pa-vis/src/sdl.rs index 1823b91d..849f6b98 100644 --- a/pa-vis/src/sdl.rs +++ b/pa-vis/src/sdl.rs @@ -18,9 +18,14 @@ lazy_static! { thread_local! { static SDL_CONTEXT: Sdl = sdl2::init().unwrap(); - static FONT: Font<'static, 'static> = TTF_CONTEXT - .load_font("/usr/share/fonts/TTF/OpenSans-Regular.ttf", 24) - .unwrap(); + static FONT: Font<'static, 'static> = 'font: { + for path in ["/usr/share/fonts/ttf/opensans-regular.ttf", "/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf"] { + if let Ok(font) = TTF_CONTEXT.load_font(path, 24) { + break 'font font; + } + } + panic!("Could not find font opensans-regular.ttf needed for visualizations. Please run without visualizations."); + } } fn to_point(CPos(x, y): CPos) -> Point {