File: hvar_test.py

package info (click to toggle)
fonttools 4.61.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,588 kB
  • sloc: python: 145,091; xml: 103; makefile: 24
file content (25 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from fontTools.ttLib import TTFont
from fontTools.varLib.hvar import add_HVAR
from io import StringIO
import os
import unittest
import pytest


def test_roundtrip():
    CWD = os.path.abspath(os.path.dirname(__file__))
    DATADIR = os.path.join(CWD, "data")
    ttx_path = os.path.join(DATADIR, "MutatorSans_All_Variable.ttx")
    font = TTFont()
    font.importXML(ttx_path)

    HVAR1 = StringIO()
    font.saveXML(HVAR1, tables=["HVAR"])

    del font["HVAR"]
    add_HVAR(font)

    HVAR2 = StringIO()
    font.saveXML(HVAR2, tables=["HVAR"])

    assert HVAR1.getvalue() == HVAR2.getvalue()