From 3500c6f6fd34247b8ec5b0d97588214304909238 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 09:23:05 +0100 Subject: [PATCH 01/12] Rename compile action --- pyproject.toml | 2 +- .../{workflow_action.py => compile_varc_action.py} | 2 +- tests/test_workflow.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/fontra_compile/{workflow_action.py => compile_varc_action.py} (96%) diff --git a/pyproject.toml b/pyproject.toml index d7e33c1..63ea309 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ fontra-compile = "fontra_compile.__main__:main" [project.entry-points."fontra.workflow.actions"] -fontra_compile = "fontra_compile.workflow_action" +fontra_compile = "fontra_compile.compile_varc_action" [tool.hatch.build.targets.wheel] diff --git a/src/fontra_compile/workflow_action.py b/src/fontra_compile/compile_varc_action.py similarity index 96% rename from src/fontra_compile/workflow_action.py rename to src/fontra_compile/compile_varc_action.py index 249687f..8ebbb20 100644 --- a/src/fontra_compile/workflow_action.py +++ b/src/fontra_compile/compile_varc_action.py @@ -10,7 +10,7 @@ from .builder import Builder -@registerActionClass("fontra-compile") +@registerActionClass("compile-varc") @dataclass(kw_only=True) class FontraCompileAction: destination: str diff --git a/tests/test_workflow.py b/tests/test_workflow.py index a556a3f..b057aa1 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -13,7 +13,7 @@ steps: - action: input source: "tests/data/MutatorSans.fontra" -- action: fontra-compile +- action: compile-varc destination: "output1.ttf" """ From 5cad5edcd66ced244d65f630a93be95ab472a54b Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 09:30:14 +0100 Subject: [PATCH 02/12] Parametrize test --- tests/test_workflow.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index b057aa1..e814a61 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1,6 +1,7 @@ import pathlib import subprocess +import pytest import yaml from fontra.workflow.workflow import Workflow from test_compile import cleanupTTX @@ -9,18 +10,24 @@ dataDir = testDir / "data" -testWorkFlow = """ +testData = [ + ( + """ steps: - action: input source: "tests/data/MutatorSans.fontra" - action: compile-varc destination: "output1.ttf" -""" +""", + "MutatorSans.ttx", + ) +] -async def test_workflow(tmpdir): +@pytest.mark.parametrize("workflowSource, ttxFileName", testData) +async def test_workflow(tmpdir, workflowSource, ttxFileName): tmpdir = pathlib.Path(tmpdir) - config = yaml.safe_load(testWorkFlow) + config = yaml.safe_load(workflowSource) workflow = Workflow(config=config) @@ -29,7 +36,7 @@ async def test_workflow(tmpdir): for output in endPoints.outputs: await output.process(tmpdir) - ttxPath = dataDir / "MutatorSans.ttx" + ttxPath = dataDir / ttxFileName outPath = tmpdir / output.destination outTTXPath = tmpdir / (outPath.stem + ".ttx") subprocess.run(["ttx", outPath], check=True) From fcd365397cb45c5eae60dbec6465d2c466de9419 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:05:33 +0100 Subject: [PATCH 03/12] Add some font info --- tests/data/MutatorSans.fontra/font-data.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/data/MutatorSans.fontra/font-data.json b/tests/data/MutatorSans.fontra/font-data.json index b22c6dd..34c140b 100644 --- a/tests/data/MutatorSans.fontra/font-data.json +++ b/tests/data/MutatorSans.fontra/font-data.json @@ -1,5 +1,12 @@ { "unitsPerEm": 1000, +"fontInfo": { +"familyName": "MutatorMathTest", +"versionMajor": 1, +"versionMinor": 2, +"copyright": "License same as MutatorMath. BSD 3-clause. [test-token: C]", +"licenseDescription": "License same as MutatorMath. BSD 3-clause. [test-token: C]" +}, "lib": {}, "axes": [ { From e5fa04341848d083af15471e0389e0b93532fda8 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:05:45 +0100 Subject: [PATCH 04/12] Configure fontmake action --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 63ea309..3b23519 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,8 @@ fontra-compile = "fontra_compile.__main__:main" [project.entry-points."fontra.workflow.actions"] -fontra_compile = "fontra_compile.compile_varc_action" +compile_varc = "fontra_compile.compile_varc_action" +compile_fontmake = "fontra_compile.compile_fontmake_action" [tool.hatch.build.targets.wheel] From 82b332e6b10ad710e557afe2ba927685c094e751 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:06:01 +0100 Subject: [PATCH 05/12] Add test for fontmake action --- tests/test_workflow.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index e814a61..c91369f 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -20,7 +20,17 @@ destination: "output1.ttf" """, "MutatorSans.ttx", - ) + ), + ( + """ +steps: +- action: input + source: "tests/data/MutatorSans.fontra" +- action: compile-fontmake + destination: "output-fontmake.ttf" +""", + "MutatorSans-fontmake.ttx", + ), ] @@ -38,8 +48,9 @@ async def test_workflow(tmpdir, workflowSource, ttxFileName): await output.process(tmpdir) ttxPath = dataDir / ttxFileName outPath = tmpdir / output.destination + assert outPath.exists(), outPath outTTXPath = tmpdir / (outPath.stem + ".ttx") - subprocess.run(["ttx", outPath], check=True) + subprocess.run(["ttx", "-o", outTTXPath, outPath], check=True) ttxLines = cleanupTTX(outTTXPath.read_text()) expectedLines = cleanupTTX(ttxPath.read_text()) From b1422ab3457f63f148f470937d8bbb4aff5f58ff Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:07:09 +0100 Subject: [PATCH 06/12] Add fontmake as requirement --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 3b7bf3e..79d6cf4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ fonttools==4.43.0 +fontmake==3.8.1 git+https://github.com/googlefonts/fontra.git git+https://github.com/googlefonts/fontra-rcjk.git From 600c53c202fe616a1df91cba6e1bed2864f92821 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:07:40 +0100 Subject: [PATCH 07/12] Add fontmake action --- src/fontra_compile/compile_fontmake_action.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/fontra_compile/compile_fontmake_action.py diff --git a/src/fontra_compile/compile_fontmake_action.py b/src/fontra_compile/compile_fontmake_action.py new file mode 100644 index 0000000..eb0dab3 --- /dev/null +++ b/src/fontra_compile/compile_fontmake_action.py @@ -0,0 +1,55 @@ +import os +import pathlib +import subprocess +import tempfile +from contextlib import aclosing, asynccontextmanager +from dataclasses import dataclass, field +from typing import AsyncGenerator + +from fontra.backends import newFileSystemBackend +from fontra.backends.copy import copyFont +from fontra.core.protocols import ReadableFontBackend +from fontra.workflow.actions import OutputActionProtocol, registerActionClass + + +@registerActionClass("compile-fontmake") +@dataclass(kw_only=True) +class CompileFontMakeAction: + destination: str + input: ReadableFontBackend | None = field(init=False, default=None) + + @asynccontextmanager + async def connect( + self, input: ReadableFontBackend + ) -> AsyncGenerator[ReadableFontBackend | OutputActionProtocol, None]: + self.input = input + try: + yield self + finally: + self.input = None + + async def process(self, outputDir: os.PathLike = pathlib.Path()) -> None: + outputDir = pathlib.Path(outputDir) + outputFontPath = outputDir / self.destination + + with tempfile.TemporaryDirectory() as tmpDirName: + tmpDir = pathlib.Path(tmpDirName) + + designspacePath = tmpDir / "temp.designspace" + + dsBackend = newFileSystemBackend(designspacePath) + + async with aclosing(dsBackend): + await copyFont(self.input, dsBackend) + + # assert 0, [p.name for p in tmpDir.iterdir()] + command = [ + "fontmake", + "-m", + designspacePath, + "-o", + "variable", + "--output-path", + os.fspath(outputFontPath), + ] + subprocess.run(command, check=True) From 4a63eafd5f2d82f6bbde759e54cf1d2f41827d8c Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:08:58 +0100 Subject: [PATCH 08/12] Add fontmake as depedency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3b23519..18a7121 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ authors = [ ] keywords = ["font", "fonts"] license = {text = "GNU General Public License v3"} -dependencies = ["fontra"] +dependencies = ["fontra", "fontmake"] dynamic = ["version"] requires-python = ">=3.10" classifiers = [ From 82264879edc1a3563451bdbfdbeff519a0cc086f Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:12:57 +0100 Subject: [PATCH 09/12] Update requirements --- requirements-dev.txt | 8 ++++---- requirements.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2634433..01e605a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -mypy==1.8.0 -pre-commit==3.3.3 -pytest==7.3.2 -types-PyYAML==6.0.12.12 +mypy==1.9.0 +pre-commit==3.6.2 +pytest==8.1.1 +types-PyYAML==6.0.12.20240311 diff --git a/requirements.txt b/requirements.txt index 79d6cf4..fa18f1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -fonttools==4.43.0 +fonttools==4.50.0 fontmake==3.8.1 git+https://github.com/googlefonts/fontra.git git+https://github.com/googlefonts/fontra-rcjk.git From 138def23d42474c1fb324e90de60336ecd67ee16 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:20:58 +0100 Subject: [PATCH 10/12] Add expected ttx --- tests/data/MutatorSans-fontmake.ttx | 5387 +++++++++++++++++++++++++++ 1 file changed, 5387 insertions(+) create mode 100644 tests/data/MutatorSans-fontmake.ttx diff --git a/tests/data/MutatorSans-fontmake.ttx b/tests/data/MutatorSans-fontmake.ttx new file mode 100644 index 0000000..fc9d925 --- /dev/null +++ b/tests/data/MutatorSans-fontmake.ttx @@ -0,0 +1,5387 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Width + + + Weight + + + License same as MutatorMath. BSD 3-clause. [test-token: C] + + + MutatorMathTest + + + Regular + + + 1.002;NONE;MutatorMathTest-Regular + + + MutatorMathTest Regular + + + Version 1.002 + + + MutatorMathTest-Regular + + + License same as MutatorMath. BSD 3-clause. [test-token: C] + + + Width + + + Weight + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + wdth + 0x0 + 0.0 + 0.0 + 1000.0 + 256 + + + + + wght + 0x0 + 100.0 + 100.0 + 900.0 + 257 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 14eff2e335d2030e909b3a4cdd05521f57cace1b Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:21:20 +0100 Subject: [PATCH 11/12] Allow fontmake options to pass through --- src/fontra_compile/compile_fontmake_action.py | 7 +++++++ tests/test_workflow.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fontra_compile/compile_fontmake_action.py b/src/fontra_compile/compile_fontmake_action.py index eb0dab3..a93040d 100644 --- a/src/fontra_compile/compile_fontmake_action.py +++ b/src/fontra_compile/compile_fontmake_action.py @@ -16,6 +16,7 @@ @dataclass(kw_only=True) class CompileFontMakeAction: destination: str + options: dict[str, str] = field(default_factory=dict) input: ReadableFontBackend | None = field(init=False, default=None) @asynccontextmanager @@ -52,4 +53,10 @@ async def process(self, outputDir: os.PathLike = pathlib.Path()) -> None: "--output-path", os.fspath(outputFontPath), ] + + for option, value in self.options.items(): + command.append(f"--{option}") + if value: + command.append(value) + subprocess.run(command, check=True) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index c91369f..056c180 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -27,6 +27,8 @@ - action: input source: "tests/data/MutatorSans.fontra" - action: compile-fontmake + options: + flatten-components: # no value destination: "output-fontmake.ttf" """, "MutatorSans-fontmake.ttx", @@ -54,4 +56,4 @@ async def test_workflow(tmpdir, workflowSource, ttxFileName): ttxLines = cleanupTTX(outTTXPath.read_text()) expectedLines = cleanupTTX(ttxPath.read_text()) - assert expectedLines == ttxLines + assert expectedLines == ttxLines, outTTXPath From 1eed8cefa74fd4812a51fe39c5b3f607223fbff9 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 20 Mar 2024 10:22:54 +0100 Subject: [PATCH 12/12] Fix mypy complaints --- src/fontra_compile/compile_fontmake_action.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fontra_compile/compile_fontmake_action.py b/src/fontra_compile/compile_fontmake_action.py index a93040d..84f07d9 100644 --- a/src/fontra_compile/compile_fontmake_action.py +++ b/src/fontra_compile/compile_fontmake_action.py @@ -30,6 +30,7 @@ async def connect( self.input = None async def process(self, outputDir: os.PathLike = pathlib.Path()) -> None: + assert self.input is not None outputDir = pathlib.Path(outputDir) outputFontPath = outputDir / self.destination @@ -47,7 +48,7 @@ async def process(self, outputDir: os.PathLike = pathlib.Path()) -> None: command = [ "fontmake", "-m", - designspacePath, + os.fspath(designspacePath), "-o", "variable", "--output-path",