| 1 |
from fontFeatures import FontFeatures, Substitution, Routine |
| 2 |
from fontFeatures.shaperLib.Buffer import Buffer |
| 3 |
from fontFeatures.shaperLib.Shaper import Shaper |
| 4 |
from babelfont import load |
| 5 |
import pytest |
| 6 |
|
| 7 |
|
| 8 |
@pytest.mark.skip("Font too broken to use") |
| 9 |
def test_double_application(): |
| 10 |
font = load("tests/data/acbe26ce904463c690fb67f70679447059d13ee4.otf") |
| 11 |
buf = Buffer(font, glyphs=["dvKA", "dvVirama", "dvKA", "dvVirama", "dvKA"]) |
| 12 |
rule = Substitution([["dvKA"], ["dvVirama"]], [["dvK"]]) |
| 13 |
rule.apply_to_buffer(buf) |
| 14 |
assert buf.serialize(position=False) == "dvK|dvK|dvKA" |
| 15 |
|
| 16 |
|
| 17 |
def test_multiple_applications(): |
| 18 |
font = load("tests/data/LibertinusSans-Regular.otf") |
| 19 |
buf = Buffer(font, glyphs=["A", "B", "C"]) |
| 20 |
r = Routine() |
| 21 |
r.addRule(Substitution([["A"]], [["X"]])) |
| 22 |
r.addRule(Substitution([["B"]], [["Y"]])) |
| 23 |
r.apply_to_buffer(buf) |
| 24 |
assert buf.serialize(position=False) == "X|Y|C" |
| 25 |
|
| 26 |
|
| 27 |
def test_namedclass_in_slot(): |
| 28 |
font = load("tests/data/LibertinusSans-Regular.otf") |
| 29 |
buf = Buffer(font, glyphs=["A", "B", "C"]) |
| 30 |
r = Routine() |
| 31 |
r.addRule(Substitution([["G", "@AB"]], [["X"]])) |
| 32 |
r.apply_to_buffer(buf, namedclasses={"AB": ["A", "B"]}) |
| 33 |
assert buf.serialize(position=False) == "X|X|C" |