-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,11 @@ jobs: | |
- name: Set up build tools | ||
run: | | ||
apt-get update | ||
apt-get install -y python3-pip protobuf-compiler | ||
apt-get install -y python3-pip protobuf-compiler curl | ||
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - | ||
apt-get install -y nodejs | ||
pip install -U fonttools | ||
npm install -g lv_font_conv | ||
- name: Cache west modules | ||
uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
config/boards/arm/hw75_dynamic/app/screen/fonts/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
add_subdirectory(zfull_9) | ||
|
||
zephyr_library_sources(icons_19.c) | ||
zephyr_compile_options(-DLV_LVGL_H_INCLUDE_SIMPLE) |
25 changes: 25 additions & 0 deletions
25
config/boards/arm/hw75_dynamic/app/screen/fonts/zfull_9/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
zephyr_library() | ||
|
||
set(FONT_SRC Zfull-GB.ttf) | ||
|
||
set(FONT_NAME zfull) | ||
set(FONT_SIZE 9) | ||
|
||
include(${ZMK_CONFIG}/cmake/font_subset.cmake) | ||
font_subset(FONT_SUBSET_TTF ${FONT_SRC} ${STRINGS_TXT}) | ||
|
||
include(${ZMK_CONFIG}/cmake/lv_font_conv.cmake) | ||
lv_font_conv(FONT_C_SRCS ${FONT_SUBSET_TTF} | ||
NAME ${FONT_NAME} | ||
SIZE ${FONT_SIZE} | ||
BPP 1 | ||
NO_PREFILTER | ||
NO_KERNING | ||
) | ||
|
||
zephyr_library_sources(${FONT_C_SRCS}) | ||
zephyr_library_include_directories(${ZEPHYR_LVGL_MODULE_DIR}) | ||
zephyr_library_include_directories(${ZEPHYR_BASE}/lib/gui/lvgl) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
STRING_LAYER_VOL,音量 | ||
STRING_LAYER_BRI,亮度 | ||
STRING_LAYER_SCR,滚动 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
function(FONT_SUBSET OUT SRC TEXT) | ||
file(REAL_PATH ${SRC} FONT_FILE) | ||
file(REAL_PATH ${TEXT} TEXT_FILE) | ||
|
||
get_filename_component(FONT_NAME ${SRC} NAME_WE) | ||
get_filename_component(FONT_EXT ${SRC} EXT) | ||
|
||
set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${FONT_NAME}_subset${FONT_EXT}) | ||
set(${OUT} ${OUTPUT_FILE} PARENT_SCOPE) | ||
|
||
add_custom_command( | ||
OUTPUT ${OUTPUT_FILE} | ||
COMMAND pyftsubset | ||
ARGS ${FONT_FILE} | ||
--text-file=${TEXT_FILE} | ||
--output-file=${OUTPUT_FILE} | ||
DEPENDS ${FONT_FILE} | ||
${TEXT_FILE} | ||
COMMENT "Generating subset font: ${FONT_NAME}_subset${FONT_EXT}" | ||
) | ||
|
||
set_source_files_properties( | ||
${OUTPUT_FILE} | ||
PROPERTIES GENERATED TRUE | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
function(LV_FONT_CONV OUT SRC) | ||
set(options NO_COMPRESS NO_PREFILTER NO_KERNING) | ||
set(one_value_keywords NAME SIZE BPP) | ||
set(multi_value_keywords RANGE) | ||
cmake_parse_arguments(LV_FONT_CONV | ||
"${options}" | ||
"${one_value_keywords}" | ||
"${multi_value_keywords}" | ||
${ARGN} | ||
) | ||
|
||
file(REAL_PATH ${SRC} FONT_SRC) | ||
|
||
set(FONT_OUT ${CMAKE_CURRENT_BINARY_DIR}/${LV_FONT_CONV_NAME}_${LV_FONT_CONV_SIZE}.c) | ||
set(${OUT} ${FONT_OUT} PARENT_SCOPE) | ||
|
||
set(LV_FONT_CONV_OPTS) | ||
|
||
if(LV_FONT_CONV_NO_COMPRESS) | ||
list(APPEND LV_FONT_CONV_OPTS "--no-compress") | ||
endif() | ||
|
||
if(LV_FONT_CONV_NO_PREFILTER) | ||
list(APPEND LV_FONT_CONV_OPTS "--no-prefilter") | ||
endif() | ||
|
||
if(LV_FONT_CONV_NO_KERNING) | ||
list(APPEND LV_FONT_CONV_OPTS "--no-kerning") | ||
endif() | ||
|
||
if (LV_FONT_CONV_RANGE) | ||
string(JOIN "," LV_FONT_CONV_RANGE ${LV_FONT_CONV_RANGE}) | ||
else() | ||
set(LV_FONT_CONV_RANGE "0x0000-0xFFFF") | ||
endif() | ||
|
||
add_custom_command( | ||
OUTPUT ${FONT_OUT} | ||
COMMAND lv_font_conv | ||
ARGS --size ${FONT_SIZE} | ||
--output "${FONT_OUT}" | ||
--bpp ${LV_FONT_CONV_BPP} | ||
--format lvgl | ||
--font "${FONT_SRC}" | ||
--range ${LV_FONT_CONV_RANGE} | ||
${LV_FONT_CONV_OPTS} | ||
DEPENDS ${FONT_SRC} | ||
${LV_FONT_CONV_RANGE_FILE} | ||
COMMENT "Generating font in LVGL format: ${FONT_NAME}_${FONT_SIZE}.c" | ||
) | ||
|
||
set_source_files_properties( | ||
${FONT_OUT} | ||
PROPERTIES GENERATED TRUE | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
function(GENERATE_UI_STRINGS INPUT) | ||
set(options) | ||
set(one_value_keywords OUTPUT_DEFS OUTPUT_TEXT) | ||
set(multi_value_keywords) | ||
cmake_parse_arguments(UI_STRINGS | ||
"${options}" | ||
"${one_value_keywords}" | ||
"${multi_value_keywords}" | ||
${ARGN} | ||
) | ||
|
||
file(REAL_PATH ${INPUT} INPUT) | ||
|
||
get_filename_component(NAME ${INPUT} NAME_WE) | ||
|
||
set(DEFS_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h) | ||
set(TEXT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.txt) | ||
|
||
add_custom_command( | ||
OUTPUT ${DEFS_FILE} ${TEXT_FILE} | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ui_strings.py | ||
ARGS --input ${INPUT} | ||
--output-defs ${DEFS_FILE} | ||
--output-text ${TEXT_FILE} | ||
DEPENDS ${INPUT} | ||
COMMENT "Generating UI strings: ${NAME}.h, ${NAME}.txt" | ||
) | ||
|
||
set_source_files_properties( | ||
${DEFS_FILE} | ||
${TEXT_FILE} | ||
PROPERTIES GENERATED TRUE | ||
) | ||
|
||
set(${UI_STRINGS_OUTPUT_DEFS} ${DEFS_FILE} PARENT_SCOPE) | ||
set(${UI_STRINGS_OUTPUT_TEXT} ${TEXT_FILE} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import argparse | ||
import csv | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--input', type=str, required=True) | ||
parser.add_argument('--output-defs', type=str, required=True) | ||
parser.add_argument('--output-text', type=str, required=True) | ||
args = parser.parse_args() | ||
|
||
with open(args.input, 'r') as f_in, open(args.output_defs, 'w') as f_od, open(args.output_text, 'w') as f_ot: | ||
reader = csv.reader(f_in) | ||
for row in reader: | ||
key, value = row | ||
text = value.strip().replace('\\n', '') | ||
f_od.write(f'#define {key} "{value}"\n') | ||
f_ot.write(f'{text}\n') | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters