File: test_glyphs3fea.py

package info (click to toggle)
python-babelfont 3.0.6~ds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,740 kB
  • sloc: xml: 33,013; python: 5,762; makefile: 68
file content (20 lines) | stat: -rw-r--r-- 958 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from babelfont.fontFilters.glyphs3fea import _translate
from babelfont import Font, Axis


def test_translate():
    testfont = Font()
    testfont.axes = [Axis(None, "wght", None, 400, 600, 900)]
    code = "sub a by b;\n#ifdef VARIABLE\ncondition 600 < wght < 900; sub dollar by dollar.alt;\n#endif"
    newcode = _translate(code, {"index": 0, "font": testfont, "tag": "rclt"})
    assert (
        newcode
        == "sub a by b;\n;} rclt;conditionset __condition_rclt_1 {wght 600 900;} __condition_rclt_1;variation rclt __condition_rclt_1 { sub dollar by dollar.alt;\n"
    )

    code = "sub a by b;\n#ifdef VARIABLE\ncondition wght < 900; sub dollar by dollar.alt;\n#endif"
    newcode = _translate(code, {"index": 0, "font": testfont, "tag": "rclt"})
    assert (
        newcode
        == "sub a by b;\n;} rclt;conditionset __condition_rclt_1 {wght 400 900;} __condition_rclt_1;variation rclt __condition_rclt_1 { sub dollar by dollar.alt;\n"
    )