diff --git a/.gitignore b/.gitignore index 46f6ea7..ca5f00c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,185 @@ master_ufo NotoSans Nunito -/target -Cargo.lock *.ufo *.ttf *.otf *.ttx .DS_Store + +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/fonticulus/test/harness.py b/fonticulus/test/harness.py index cb31350..6c7a9e9 100644 --- a/fonticulus/test/harness.py +++ b/fonticulus/test/harness.py @@ -1,7 +1,6 @@ -import argparse import pytest import tempfile -import pathlib +from pathlib import Path import subprocess import sys import io @@ -13,8 +12,8 @@ environment = os.environ.get("ENVIRONMENT", "debug") -fonticulus = pathlib.Path(__file__).parent.parent.parent / "target" / environment / "fonticulus" -home_dir = pathlib.Path(__file__).parent.resolve() +fonticulus = Path(__file__).parent.parent.parent / "target" / environment / "fonticulus" +home_dir = Path(__file__).parent.resolve() test_files = [pytest.param(x, id=x.name) for x in (home_dir / 'sources').glob("*.*")] def clean_font(ttjfont): @@ -28,8 +27,8 @@ def clean_font(ttjfont): del ttjfont["gvar"] # FOR NOW return ttjfont -def get_expectation(source: pathlib.Path): - expectation_file = home_dir / "expectation" / (pathlib.Path(source).name + ".expected") +def get_expectation(source: Path): + expectation_file = home_dir / "expectation" / (Path(source).name + ".expected") expectation_file.parent.mkdir(exist_ok=True) if not expectation_file.exists(): # Compile with fontmake @@ -41,10 +40,11 @@ def get_expectation(source: pathlib.Path): build_arg = "-o variable -m" else: raise ValueError("Unknown source file type") - with tempfile.NamedTemporaryFile() as tf: - cmd = f"fontmake {build_arg} {source} --keep-overlaps --output-path {tf.name}" + with tempfile.TemporaryDirectory() as td: + filename = Path(td) / "out.ttf" + cmd = f"fontmake --verbose WARNING {build_arg} {source} --keep-overlaps --output-path {filename}" subprocess.run(cmd, shell=True, check=True) - ttjfont = TTJ(TTFont(tf)) + ttjfont = TTJ(TTFont(filename)) as_json = json.dumps(ttjfont, indent=4) with expectation_file.open("w") as f: f.write(as_json) diff --git a/fonticulus/test/requirements.in b/fonticulus/test/requirements.in new file mode 100644 index 0000000..99130b7 --- /dev/null +++ b/fonticulus/test/requirements.in @@ -0,0 +1,3 @@ +fontmake +pytest +recursive-diff