2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-11-09 03:47:39 +08:00
|
|
|
# These functions can be used to generate a CFB font include file from
|
|
|
|
# a TrueType/OpenType font file or an image file.
|
|
|
|
function(generate_cfb_font
|
|
|
|
input_file # The TrueType/OpenType font file or the image file
|
|
|
|
output_file # The generated header file
|
|
|
|
width # Width of the CFB font elements in pixels
|
|
|
|
height # Height of the CFB font elements in pixels
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${output_file}
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
2022-07-11 22:59:14 +08:00
|
|
|
${ZEPHYR_BASE}/scripts/build/gen_cfb_font_header.py
|
2020-02-12 22:42:09 +08:00
|
|
|
--zephyr-base ${ZEPHYR_BASE}
|
2018-11-09 03:47:39 +08:00
|
|
|
--input ${input_file}
|
|
|
|
--output ${output_file}
|
2019-06-12 06:50:04 +08:00
|
|
|
--bindir ${CMAKE_BINARY_DIR}
|
2018-11-09 03:47:39 +08:00
|
|
|
--width ${width}
|
|
|
|
--height ${height}
|
|
|
|
${ARGN} # Extra arguments are passed to gen_cfb_font_header.py
|
|
|
|
DEPENDS ${source_file}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(generate_cfb_font_for_gen_target
|
|
|
|
target # The cmake target that depends on the generated file
|
|
|
|
input_file # The TrueType/OpenType font file or the image file
|
|
|
|
output_file # The generated header file
|
|
|
|
width # Width of the CFB font elements in pixels
|
|
|
|
height # Height of the CFB font elements in pixels
|
|
|
|
gen_target # The generated file target we depend on
|
|
|
|
# Any additional arguments are passed on to
|
|
|
|
# gen_cfb_font_header.py
|
|
|
|
)
|
|
|
|
generate_cfb_font(${input_file} ${output_file} ${width} ${height} ${ARGN})
|
|
|
|
|
|
|
|
# Ensure 'output_file' is generated before 'target' by creating a
|
|
|
|
# dependency between the two targets
|
|
|
|
|
|
|
|
add_dependencies(${target} ${gen_target})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(generate_cfb_font_for_target
|
|
|
|
target # The cmake target that depends on the generated file
|
|
|
|
input_file # The TrueType/OpenType font file or image file
|
|
|
|
output_file # The generated header file
|
|
|
|
width # Width of the CFB font elements in pixels
|
|
|
|
height # Height of the CFB font elements in pixels
|
|
|
|
# Any additional arguments are passed on to
|
|
|
|
# gen_cfb_font_header.py
|
|
|
|
)
|
|
|
|
# Ensure 'output_file' is generated before 'target' by creating a
|
|
|
|
# 'custom_target' for it and setting up a dependency between the two
|
|
|
|
# targets
|
|
|
|
|
|
|
|
# But first create a unique name for the custom target
|
|
|
|
generate_unique_target_name_from_filename(${output_file} generated_target_name)
|
|
|
|
|
|
|
|
add_custom_target(${generated_target_name} DEPENDS ${output_file})
|
|
|
|
generate_cfb_font_for_gen_target(${target} ${input_file} ${output_file}
|
|
|
|
${width} ${height} ${generated_target_name} ${ARGN})
|
|
|
|
endfunction()
|