diff --git a/solid/core/scad_import.py b/solid/core/scad_import.py index 9ea7d1f9..e626fc82 100644 --- a/solid/core/scad_import.py +++ b/solid/core/scad_import.py @@ -1,4 +1,5 @@ from types import SimpleNamespace +from pathlib import Path import inspect from .utils import resolve_scad_filename, escape_openscad_identifier @@ -8,6 +9,7 @@ # = IMPORTING OPENSCAD CODE = # =========================== module_cache_by_resolved_filename = {} +registered_fonts = [] def check_module_cache(resolved_scad, use_not_include): global module_cache_by_resolved_filename @@ -96,6 +98,14 @@ def get_callers_namespace_dict(depth=2): return frame.f_globals def use(filename): + #is this a font to register? + p_file = Path(filename) + if p_file.suffix == ".ttf" or p_file.suffix == ".otf": + global registered_fonts + registered_fonts += [p_file] + return + + #otherwise load the scad file load_scad_file_or_dir_into_dict(filename, get_callers_namespace_dict(), True) def include(filename): diff --git a/solid/core/scad_render.py b/solid/core/scad_render.py index b164682c..80a88005 100644 --- a/solid/core/scad_render.py +++ b/solid/core/scad_render.py @@ -2,7 +2,7 @@ from .utils import indent from .object_base import ObjectBase, OpenSCADObject -from .scad_import import module_cache_by_resolved_filename +from .scad_import import module_cache_by_resolved_filename, registered_fonts from ..config import config # ========================================= @@ -77,6 +77,9 @@ def get_include_string(): else: strings.append(f"include <{k}>") + for f in registered_fonts: + strings.append(f"use <{f}>") + s = "\n".join(strings) s += "\n\n" if s else ''