1# SPDX-License-Identifier: Apache-2.0 2 3# These functions can be used to generate a CFB font include file from 4# a TrueType/OpenType font file or an image file. 5function(generate_cfb_font 6 input_file # The TrueType/OpenType font file or the image file 7 output_file # The generated header file 8 width # Width of the CFB font elements in pixels 9 height # Height of the CFB font elements in pixels 10 ) 11 add_custom_command( 12 OUTPUT ${output_file} 13 COMMAND 14 ${PYTHON_EXECUTABLE} 15 ${ZEPHYR_BASE}/scripts/build/gen_cfb_font_header.py 16 --zephyr-base ${ZEPHYR_BASE} 17 --input ${input_file} 18 --output ${output_file} 19 --bindir ${CMAKE_BINARY_DIR} 20 --width ${width} 21 --height ${height} 22 ${ARGN} # Extra arguments are passed to gen_cfb_font_header.py 23 DEPENDS ${source_file} 24 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 25 ) 26endfunction() 27 28function(generate_cfb_font_for_gen_target 29 target # The cmake target that depends on the generated file 30 input_file # The TrueType/OpenType font file or the image file 31 output_file # The generated header file 32 width # Width of the CFB font elements in pixels 33 height # Height of the CFB font elements in pixels 34 gen_target # The generated file target we depend on 35 # Any additional arguments are passed on to 36 # gen_cfb_font_header.py 37 ) 38 generate_cfb_font(${input_file} ${output_file} ${width} ${height} ${ARGN}) 39 40 # Ensure 'output_file' is generated before 'target' by creating a 41 # dependency between the two targets 42 43 add_dependencies(${target} ${gen_target}) 44endfunction() 45 46function(generate_cfb_font_for_target 47 target # The cmake target that depends on the generated file 48 input_file # The TrueType/OpenType font file or image file 49 output_file # The generated header file 50 width # Width of the CFB font elements in pixels 51 height # Height of the CFB font elements in pixels 52 # Any additional arguments are passed on to 53 # gen_cfb_font_header.py 54 ) 55 # Ensure 'output_file' is generated before 'target' by creating a 56 # 'custom_target' for it and setting up a dependency between the two 57 # targets 58 59 # But first create a unique name for the custom target 60 generate_unique_target_name_from_filename(${output_file} generated_target_name) 61 62 add_custom_target(${generated_target_name} DEPENDS ${output_file}) 63 generate_cfb_font_for_gen_target(${target} ${input_file} ${output_file} 64 ${width} ${height} ${generated_target_name} ${ARGN}) 65endfunction() 66