Skip to content

Commit 3c1d1f9

Browse files
authored
chore: Allow configuring diag font path at build time (#1523)
1 parent fb253fd commit 3c1d1f9

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ set(CASPARCG_DOWNLOAD_CACHE ${CMAKE_CURRENT_BINARY_DIR}/external CACHE STRING "D
1212

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

15+
set(DIAG_FONT_PATH "LiberationMono-Regular.ttf" CACHE STRING
16+
"Path to font that will be used to load diag font at runtime. By default
17+
this loads the font distribtued with the application from the working
18+
directory. It can be set to an absolute path to instead load a font from
19+
the system."
20+
)
21+
add_compile_definitions("DIAG_FONT_PATH=\"${DIAG_FONT_PATH}\"")
22+
1523
# Add custom cmake modules path
1624
SET (CASPARCG_PATCH_DIR ${CMAKE_SOURCE_DIR}/CMakeModules/patches)
1725
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)

src/CMakeModules/Bootstrap_Linux.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ if (NOT USE_STATIC_BOOST)
114114
ADD_DEFINITIONS (-DBOOST_ALL_DYN_LINK)
115115
endif()
116116

117-
if (USE_SYSTEM_DIAG_FONT)
118-
ADD_DEFINITIONS(-DUSE_SYSTEM_DIAG_FONT)
119-
endif()
120-
121117
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
122118
ADD_COMPILE_OPTIONS (-O3) # Needed for precompiled headers to work
123119
endif()

src/core/diagnostics/osd_graph.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@ sf::Font& get_default_font()
6666
{
6767
static sf::Font DEFAULT_FONT = []() {
6868
sf::Font font;
69-
#ifdef USE_SYSTEM_DIAG_FONT
70-
if (!font.loadFromFile("/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"))
71-
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(
72-
"/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf not found"));
73-
#else
74-
if (!font.loadFromFile("LiberationMono-Regular.ttf"))
75-
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info("LiberationMono-Regular.ttf not found"));
76-
#endif
69+
if (!font.loadFromFile(DIAG_FONT_PATH))
70+
CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(DIAG_FONT_PATH " not found"));
7771
return font;
7872
}();
7973

0 commit comments

Comments
 (0)