Skip to content

Commit

Permalink
Test that our CFF2CharStringMergePen source order fix is effective
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Jul 13, 2024
1 parent 48b5366 commit b87d94b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
from __future__ import annotations

import pathlib
import random
import subprocess
from dataclasses import dataclass, replace

import pytest
import yaml
from fontra.core.classes import VariableGlyph
from fontra.workflow.actions import registerFilterAction
from fontra.workflow.actions.base import BaseFilter
from fontra.workflow.workflow import Workflow
from test_compile import cleanupTTX

testDir = pathlib.Path(__file__).resolve().parent
dataDir = testDir / "data"


@registerFilterAction("randomize-glyph-source-order")
@dataclass(kw_only=True)
class RandomizeGlyphSourceOrder(BaseFilter):
async def processGlyph(self, glyph: VariableGlyph) -> VariableGlyph:
newSources = list(glyph.sources)
random.shuffle(newSources)
return replace(glyph, sources=newSources)


testData = [
(
"""
Expand All @@ -33,6 +49,20 @@
),
(
"""
# This test confirms that the order of sources in glyphs is irrelevant.
# In other words, check that we produce the same output regardless of glyph
# source order.
steps:
- input: fontra-read
source: "tests/data/MutatorSans.fontra"
- filter: randomize-glyph-source-order
- output: compile-varc
destination: "output-random-source-order.otf"
""",
"MutatorSans.otf.ttx",
),
(
"""
steps:
- input: fontra-read
source: "tests/data/MutatorSans.fontra"
Expand Down

0 comments on commit b87d94b

Please sign in to comment.