generalize lv-font creation
In https://github.com/InfiniTimeOrg/InfiniTime/pull/1097 new font generation capabilites were added. Generalize the font creation to make it possible to reuse the `displayapp/fonts/CMakeLists.txt` file for `InfiniSim` and just add the new cmake file to the project and link against the new `infinitime_fonts` target. In the following a list of changes. Allow non-global installed `lv_font_conv` executable installed with ```sh npm install lv_font_conv@1.5.2 ``` In CMake we search for `lv_font_conv` executable. Add the found executable to the python script `generate.py`, to remove the need for `lv_font_conv` to be in the path. Search for `python3` executable, if CMake version 3.12 is available. Otherwise use `python` as hard coded executable. Instead of adding the generated fonts to `SOURCE_FILES` variable, create a static library `infinitime_fonts`. Link this library to the executables instead. Use `add_custom_target()` together with `add_custom_command()` to generate the font.c files once (like the original PR does).
This commit is contained in:

committed by
Riku Isokoski

parent
8485cdb54d
commit
db0f909b46
@@ -18,8 +18,8 @@ class Source(object):
|
||||
self.symbols = d.get('symbols')
|
||||
|
||||
|
||||
def gen_lvconv_line(dest: str, size: int, bpp: int, sources: typing.List[Source], compress:bool=False):
|
||||
args = ['lv_font_conv', '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', 'lvgl']
|
||||
def gen_lvconv_line(lv_font_conv: str, dest: str, size: int, bpp: int, sources: typing.List[Source], compress:bool=False):
|
||||
args = [lv_font_conv, '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', 'lvgl']
|
||||
if not compress:
|
||||
args.append('--no-compress')
|
||||
for source in sources:
|
||||
@@ -35,9 +35,10 @@ 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('lv_font_conv'):
|
||||
if not shutil.which(args.lv_font_conv):
|
||||
sys.exit(f'Missing lv_font_conv. (make sure it is installed and in PATH)')
|
||||
if not os.path.exists(args.config):
|
||||
sys.exit(f'Error: the config file {args.config} does not exist.')
|
||||
@@ -62,7 +63,7 @@ def main():
|
||||
sources = font.pop('sources')
|
||||
patches = font.pop('patches') if 'patches' in font else []
|
||||
font['sources'] = [Source(thing) for thing in sources]
|
||||
line = gen_lvconv_line(f'{name}.c', **font)
|
||||
line = gen_lvconv_line(args.lv_font_conv, f'{name}.c', **font)
|
||||
subprocess.check_call(line)
|
||||
if patches:
|
||||
for patch in patches:
|
||||
|
Reference in New Issue
Block a user