Skip to content

Commit

Permalink
SDL: look in multiple paths for opensans-regular.ttf
Browse files Browse the repository at this point in the history
Fix #18
  • Loading branch information
RagnarGrootKoerkamp committed Jul 25, 2023
1 parent c92d94b commit e52dcc0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pa-vis/src/sdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e52dcc0

Please sign in to comment.