forked from InfiniTimeOrg/InfiniTime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'InfiniTimeOrg:develop' into dice
- Loading branch information
Showing
19 changed files
with
607 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -22,6 +22,12 @@ RUN apt-get update -qq \ | |
python3-dev \ | ||
git \ | ||
apt-utils \ | ||
pkg-config \ | ||
libpixman-1-dev \ | ||
libcairo2-dev \ | ||
libpango-1.0-0 \ | ||
ibpango1.0-dev \ | ||
libpangocairo-1.0-0 \ | ||
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \ | ||
&& apt-get install -y nodejs \ | ||
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*; | ||
|
@@ -33,6 +39,10 @@ RUN pip3 install -Iv cryptography==3.3 | |
RUN pip3 install cbor | ||
RUN npm i [email protected] -g | ||
|
||
RUN npm i [email protected] -g | ||
RUN npm i @swc/core -g | ||
RUN npm i [email protected] -g | ||
|
||
# build.sh knows how to compile | ||
COPY build.sh /opt/ | ||
|
||
|
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
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,29 @@ | ||
|
||
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED | ||
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin") | ||
message(STATUS "Using ${LV_FONT_CONV} to generate font files") | ||
|
||
find_program(LV_IMG_CONV "lv_img_conv" NO_CACHE REQUIRED | ||
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin") | ||
message(STATUS "Using ${LV_IMG_CONV} to generate font files") | ||
|
||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) | ||
# FindPython3 module introduces with CMake 3.12 | ||
# https://cmake.org/cmake/help/latest/module/FindPython3.html | ||
find_package(Python3 REQUIRED) | ||
else() | ||
set(Python3_EXECUTABLE "python") | ||
endif() | ||
|
||
# generate fonts | ||
add_custom_target(GenerateResources | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/generate-fonts.py --lv-font-conv "${LV_FONT_CONV}" ${CMAKE_CURRENT_SOURCE_DIR}/fonts.json | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/generate-img.py --lv-img-conv "${LV_IMG_CONV}" ${CMAKE_CURRENT_SOURCE_DIR}/images.json | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/generate-package.py --config ${CMAKE_CURRENT_SOURCE_DIR}/fonts.json --config ${CMAKE_CURRENT_SOURCE_DIR}/images.json --obsolete obsolete_files.json --output infinitime-resources-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fonts.json | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/images.json | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
|
||
COMMENT "Generate fonts and images for resource package" | ||
) | ||
|
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,62 @@ | ||
{ | ||
"teko" : { | ||
"sources": [ | ||
{ | ||
"file": "fonts/Teko-Light.ttf", | ||
"symbols": "0123456789:/amp" | ||
} | ||
], | ||
"bpp": 1, | ||
"size": 28, | ||
"format": "bin", | ||
"target_path": "/fonts/" | ||
}, | ||
"bebas" : { | ||
"sources": [ | ||
{ | ||
"file": "fonts/BebasNeue-Regular.ttf", | ||
"symbols": "0123456789:" | ||
} | ||
], | ||
"bpp": 1, | ||
"size": 120, | ||
"format": "bin", | ||
"target_path": "/fonts/" | ||
}, | ||
"lv_font_dots_40": { | ||
"sources": [ | ||
{ | ||
"file": "fonts/repetitionscrolling.ttf", | ||
"symbols": "0123456789-MONTUEWEDTHUFRISATSUN WK" | ||
} | ||
], | ||
"bpp": 1, | ||
"size": 40, | ||
"format": "bin", | ||
"target_path": "/fonts/" | ||
}, | ||
"7segments_40" : { | ||
"sources": [ | ||
{ | ||
"file": "fonts/7segment.woff", | ||
"symbols": "0123456789: -" | ||
} | ||
], | ||
"bpp": 1, | ||
"size": 40, | ||
"format": "bin", | ||
"target_path": "/fonts/" | ||
}, | ||
"7segments_115" : { | ||
"sources": [ | ||
{ | ||
"file": "fonts/7segment.woff", | ||
"symbols": "0123456789: -" | ||
} | ||
], | ||
"bpp": 1, | ||
"size": 115, | ||
"format": "bin", | ||
"target_path": "/fonts/" | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
|
||
import io | ||
import sys | ||
import json | ||
import shutil | ||
import typing | ||
import os.path | ||
import argparse | ||
import subprocess | ||
|
||
class Source(object): | ||
def __init__(self, d): | ||
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.symbols = d.get('symbols') | ||
|
||
|
||
def gen_lvconv_line(lv_font_conv: str, dest: str, size: int, bpp: int, format: str, sources: typing.List[Source], compress:bool=False): | ||
if format != "lvgl" and format != "bin": | ||
format = "bin" if dest.lower().endswith(".bin") else "lvgl" | ||
|
||
args = [lv_font_conv, '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', format] | ||
if not compress: | ||
args.append('--no-compress') | ||
for source in sources: | ||
args.extend(['--font', source.file]) | ||
if source.range: | ||
args.extend(['--range', source.range]) | ||
if source.symbols: | ||
args.extend(['--symbols', source.symbols]) | ||
|
||
return args | ||
|
||
def main(): | ||
ap = argparse.ArgumentParser(description='auto generate LVGL font files from fonts') | ||
ap.add_argument('config', type=str, help='config file to use') | ||
ap.add_argument('-f', '--font', type=str, action='append', help='Choose specific fonts to generate (default: all)', default=[]) | ||
ap.add_argument('--lv-font-conv', type=str, help='Path to "lv_font_conf" executable', default="lv_font_conv") | ||
args = ap.parse_args() | ||
|
||
if not shutil.which(args.lv_font_conv): | ||
sys.exit(f"Missing lv_font_conv. Make sure it's findable (in PATH) or specify it manually") | ||
if not os.path.exists(args.config): | ||
sys.exit(f'Error: the config file {args.config} does not exist.') | ||
if not os.access(args.config, os.R_OK): | ||
sys.exit(f'Error: the config file {args.config} is not accessible (permissions?).') | ||
with open(args.config, 'r') as fd: | ||
data = json.load(fd) | ||
|
||
fonts_to_run = set(data.keys()) | ||
|
||
if args.font: | ||
enabled_fonts = set() | ||
for font in args.font: | ||
enabled_fonts.add(font[:-2] if font.endswith('.c') else font) | ||
d = enabled_fonts.difference(fonts_to_run) | ||
if d: | ||
print(f'Warning: requested font{"s" if len(d)>1 else ""} missing: {" ".join(d)}') | ||
fonts_to_run = fonts_to_run.intersection(enabled_fonts) | ||
|
||
for name in fonts_to_run: | ||
font = data[name] | ||
sources = font.pop('sources') | ||
patches = font.pop('patches') if 'patches' in font else [] | ||
font['sources'] = [Source(thing) for thing in sources] | ||
extension = 'c' if font['format'] != 'bin' else 'bin' | ||
font.pop('target_path') | ||
line = gen_lvconv_line(args.lv_font_conv, f'{name}.{extension}', **font) | ||
subprocess.check_call(line) | ||
if patches: | ||
for patch in patches: | ||
subprocess.check_call(['/usr/bin/env', 'patch', name+'.'+extension, patch]) | ||
|
||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
|
||
import io | ||
import sys | ||
import json | ||
import shutil | ||
import typing | ||
import os.path | ||
import argparse | ||
import subprocess | ||
|
||
def gen_lvconv_line(lv_img_conv: str, dest: str, color_format: str, output_format: str, binary_format: str, sources: str): | ||
args = [lv_img_conv, sources, '--force', '--output-file', dest, '--color-format', color_format, '--output-format', output_format, '--binary-format', binary_format] | ||
|
||
return args | ||
|
||
def main(): | ||
ap = argparse.ArgumentParser(description='auto generate LVGL font files from fonts') | ||
ap.add_argument('config', type=str, help='config file to use') | ||
ap.add_argument('-i', '--image', type=str, action='append', help='Choose specific images to generate (default: all)', default=[]) | ||
ap.add_argument('--lv-img-conv', type=str, help='Path to "lv_img_conf" executable', default="lv_img_conv") | ||
args = ap.parse_args() | ||
|
||
if not shutil.which(args.lv_img_conv): | ||
sys.exit(f"Missing lv_img_conv. Make sure it's findable (in PATH) or specify it manually") | ||
if not os.path.exists(args.config): | ||
sys.exit(f'Error: the config file {args.config} does not exist.') | ||
if not os.access(args.config, os.R_OK): | ||
sys.exit(f'Error: the config file {args.config} is not accessible (permissions?).') | ||
with open(args.config, 'r') as fd: | ||
data = json.load(fd) | ||
|
||
images_to_run = set(data.keys()) | ||
|
||
if args.image: | ||
enabled_images = set() | ||
for image in args.image: | ||
enabled_images.add(image[:-2] if image.endswith('.c') else image) | ||
d = enabled_images.difference(images_to_run) | ||
if d: | ||
print(f'Warning: requested image{"s" if len(d)>1 else ""} missing: {" ".join(d)}') | ||
images_to_run = images_to_run.intersection(enabled_images) | ||
|
||
for name in images_to_run: | ||
image = data[name] | ||
if not os.path.exists(image['sources']): | ||
image['sources'] = os.path.join(os.path.dirname(sys.argv[0]), image['sources']) | ||
extension = 'bin' | ||
image.pop('target_path') | ||
line = gen_lvconv_line(args.lv_img_conv, f'{name}.{extension}', **image) | ||
subprocess.check_call(line) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.