From d2f0611feaf59941accfdc3c0f5820c0fadc3514 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Tue, 30 Aug 2022 08:47:44 +0200 Subject: [PATCH] test font.normalizeLocation() --- Tests/ttLib/ttFont_test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/ttLib/ttFont_test.py b/Tests/ttLib/ttFont_test.py index e0e82b244..46aee33dd 100644 --- a/Tests/ttLib/ttFont_test.py +++ b/Tests/ttLib/ttFont_test.py @@ -212,3 +212,23 @@ def test_ensureDecompiled(lazy): assert "Lookup" in font["GSUB"].table.LookupList.__dict__ assert "reader" not in font["GPOS"].table.LookupList.__dict__ assert "Lookup" in font["GPOS"].table.LookupList.__dict__ + + +@pytest.mark.parametrize( + "userLocation, expectedNormalizedLocation", + [ + ({}, {"wght": 0.0}), + ({"wght": 100}, {"wght": -1.0}), + ({"wght": 250}, {"wght": -0.75}), + ({"wght": 400}, {"wght": 0.0}), + ({"wght": 550}, {"wght": 0.75}), + ({"wght": 625}, {"wght": 0.875}), + ({"wght": 700}, {"wght": 1.0}), + ], +) +def test_font_normalizeLocation(userLocation, expectedNormalizedLocation): + ttxpath = os.path.join(DATA_DIR, "TestTTF_normalizeLocation.ttx") + ttf = TTFont() + ttf.importXML(ttxpath) + normalizedLocation = ttf.normalizeLocation(userLocation) + assert expectedNormalizedLocation == normalizedLocation