fontgen: generate font .c files in build dir

This commit is contained in:
Yehoshua Pesach Wallach 2022-04-20 21:38:42 +03:00 committed by JF
parent e39f183efe
commit ef17f2f981
2 changed files with 9 additions and 4 deletions

View File

@ -4,13 +4,16 @@ set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
jetbrains_mono_extrabold_compressed lv_font_navi_80 lv_font_sys_48 jetbrains_mono_extrabold_compressed lv_font_navi_80 lv_font_sys_48
open_sans_light) open_sans_light)
configure_file(displayapp/fonts/jetbrains_mono_bold_20.c_zero.patch
displayapp/fonts/jetbrains_mono_bold_20.c_zero.patch COPYONLY)
foreach(FONT ${FONTS}) foreach(FONT ${FONTS})
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/${FONT}.c set_source_files_properties(displayapp/fonts/${FONT}.c
PROPERTIES GENERATED TRUE) PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/${FONT}.c add_custom_command(OUTPUT displayapp/fonts/${FONT}.c
COMMAND python generate.py -f ${FONT} fonts.json COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/generate.py
-f ${FONT} ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/fonts.json
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/fonts.json DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts/fonts.json
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/displayapp/fonts WORKING_DIRECTORY displayapp/fonts
) )
endforeach() endforeach()

View File

@ -11,6 +11,8 @@ import subprocess
class Source(object): class Source(object):
def __init__(self, d): def __init__(self, d):
self.file = d['file'] self.file = d['file']
if not os.path.exists(self.file):
self.file = os.path.join(os.path.dirname(sys.argv[0]), self.file)
self.range = d.get('range') self.range = d.get('range')
self.symbols = d.get('symbols') self.symbols = d.get('symbols')