From 94230413a44fbbf2b6da6839e3961c0775f9276a Mon Sep 17 00:00:00 2001 From: Gijs Peskens Date: Tue, 2 Jun 2020 13:51:45 +0200 Subject: [PATCH] Diag font: use path relative to executable. Fixes diag window not loading when Caspar was not started from the caspar dir (i.e.: under systemd the working dir would be /, and caspar would look for the font in / instead of the installation directory). --- src/core/diagnostics/osd_graph.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/diagnostics/osd_graph.cpp b/src/core/diagnostics/osd_graph.cpp index 62d11b4930..cec703a7c1 100644 --- a/src/core/diagnostics/osd_graph.cpp +++ b/src/core/diagnostics/osd_graph.cpp @@ -37,6 +37,8 @@ #include +#include + #include #include @@ -65,8 +67,9 @@ sf::Font& get_default_font() { static sf::Font DEFAULT_FONT = []() { sf::Font font; - if (!font.loadFromFile("LiberationMono-Regular.ttf")) - CASPAR_THROW_EXCEPTION(file_not_found() << msg_info("LiberationMono-Regular.ttf not found")); + auto font_path = boost::dll::program_location().parent_path().parent_path().string() + "/LiberationMono-Regular.ttf"; + if (!font.loadFromFile(font_path)) + CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(font_path + " not found")); return font; }();