feat(cmake): Query fonts
This commit is contained in:
parent
ef2ad7a504
commit
e20150e6ca
@ -161,3 +161,45 @@ function(make_library target_name)
|
||||
endfunction()
|
||||
|
||||
# }}}
|
||||
# find_font : Query fontconfig fonts {{{
|
||||
|
||||
function(font_query output_variable fontname)
|
||||
set(multi_value_args FIELDS)
|
||||
cmake_parse_arguments(ARG "" "" "${multi_value_args}" ${ARGN})
|
||||
|
||||
find_program(BIN_FCLIST fc-list)
|
||||
if(NOT BIN_FCLIST)
|
||||
message_colored(WARNING "Failed to locate `fc-list`" "33;1")
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" " " FIELDS "${ARG_FIELDS}")
|
||||
if(NOT FIELDS)
|
||||
set(FIELDS family)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND sh -c "${BIN_FCLIST} : ${FIELDS}"
|
||||
RESULT_VARIABLE status
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
STRING(REGEX REPLACE ";" "\\\\;" output "${output}")
|
||||
STRING(REGEX REPLACE "\n" ";" output "${output}")
|
||||
STRING(TOLOWER "${output}" output)
|
||||
|
||||
foreach(match LISTS ${output})
|
||||
if(${match} MATCHES ".*${fontname}.*$")
|
||||
list(APPEND FONT_QUERY_MATCHES ${match})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(FONT_QUERY_MATCHES)
|
||||
list(GET FONT_QUERY_MATCHES 0 output_variable)
|
||||
set(output_variable "${output_variable}" PARENT_SCOPE)
|
||||
message(STATUS "Found font: ${output_variable}")
|
||||
else()
|
||||
message_colored(WARNING "Font not found: ${fontname}" "33;1")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# }}}
|
||||
|
@ -8,6 +8,14 @@ set(MODULES_LEFT "bspwm i3 xwindow")
|
||||
set(MODULES_CENTER "")
|
||||
set(MODULES_RIGHT "xbacklight volume xkeyboard memory cpu wlan eth battery temperature date powermenu")
|
||||
|
||||
set(FONT_FIXED "fixed:pixelsize=10")
|
||||
set(FONT_UNIFONT "unifont:fontformat=truetype")
|
||||
set(FONT_SIJI "siji:pixelsize=10")
|
||||
|
||||
font_query(FONT_FIXED "${FONT_FIXED}" FIELDS family pixelsize)
|
||||
font_query(FONT_UNIFONT "${FONT_UNIFONT}" FIELDS family fontformat)
|
||||
font_query(FONT_SIJI "${FONT_SIJI}" FIELDS family pixelsize)
|
||||
|
||||
# Strip disabled modules {{{
|
||||
|
||||
if(NOT ENABLE_ALSA)
|
||||
|
@ -44,9 +44,9 @@ padding-right = 2
|
||||
module-margin-left = 1
|
||||
module-margin-right = 2
|
||||
|
||||
font-0 = fixed:pixelsize=10;0
|
||||
font-1 = unifont:size=6:heavy:fontformat=truetype;-2
|
||||
font-2 = siji:pixelsize=10;0
|
||||
font-0 = @FONT_FIXED@
|
||||
font-1 = @FONT_UNIFONT@:size=6:heavy;-2
|
||||
font-2 = @FONT_SIJI@
|
||||
|
||||
modules-left = @MODULES_LEFT@
|
||||
modules-center = @MODULES_CENTER@
|
||||
|
Loading…
Reference in New Issue
Block a user