Skip to content

Commit

Permalink
Allow configuring diag font path at build time
Browse files Browse the repository at this point in the history
This allows for better integration with distros that put the system font
in a different directory.
  • Loading branch information
oscarwcl committed Jan 17, 2024
1 parent fb253fd commit 9ee50d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ set(CASPARCG_DOWNLOAD_CACHE ${CMAKE_CURRENT_BINARY_DIR}/external CACHE STRING "D

option(ENABLE_HTML "Enable HTML module, require CEF" ON)

set(DIAG_FONT_PATH "LiberationMono-Regular.ttf" CACHE STRING
"Path to font that will be used to load diag font at runtime. By default
this loads the font distribtued with the application from the working
directory. It can be set to an absolute path to instead load a font from
the system."
)
add_compile_definitions("DIAG_FONT_PATH=\"${DIAG_FONT_PATH}\"")

# Add custom cmake modules path
SET (CASPARCG_PATCH_DIR ${CMAKE_SOURCE_DIR}/CMakeModules/patches)
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
Expand Down
6 changes: 1 addition & 5 deletions src/CMakeModules/Bootstrap_Linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (NOT USE_SYSTEM_FFMPEG)
else()
FIND_PACKAGE (FFmpeg REQUIRED)
LINK_DIRECTORIES("${FFMPEG_LIBRARY_DIRS}")

SET (FFMPEG_INCLUDE_PATH "${FFMPEG_INCLUDE_DIRS}")
endif()

Expand Down Expand Up @@ -114,10 +114,6 @@ if (NOT USE_STATIC_BOOST)
ADD_DEFINITIONS (-DBOOST_ALL_DYN_LINK)
endif()

if (USE_SYSTEM_DIAG_FONT)
ADD_DEFINITIONS(-DUSE_SYSTEM_DIAG_FONT)
endif()

IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_COMPILE_OPTIONS (-O3) # Needed for precompiled headers to work
endif()
Expand Down
10 changes: 2 additions & 8 deletions src/core/diagnostics/osd_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ sf::Font& get_default_font()
{
static sf::Font DEFAULT_FONT = []() {
sf::Font font;
#ifdef USE_SYSTEM_DIAG_FONT
if (!font.loadFromFile("/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"))
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(
"/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf not found"));
#else
if (!font.loadFromFile("LiberationMono-Regular.ttf"))
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info("LiberationMono-Regular.ttf not found"));
#endif
if (!font.loadFromFile(DIAG_FONT_PATH))
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(DIAG_FONT_PATH " not found"));
return font;
}();

Expand Down

0 comments on commit 9ee50d5

Please sign in to comment.