Skip to content

Commit

Permalink
test passing ftConfig to enable GPOS compression
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Jan 11, 2024
1 parent 63f703b commit 5b4d18f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import difflib
import io
import logging
import os
import re
import sys
from pathlib import Path
from textwrap import dedent

import pytest
from fontTools.designspaceLib import DesignSpaceDocument
from fontTools.otlLib.optimize.gpos import COMPRESSION_LEVEL as GPOS_COMPRESSION_LEVEL
from fontTools.pens.boundsPen import BoundsPen
from fontTools.pens.transformPen import TransformPen
from fontTools.ttLib.tables._g_l_y_f import (
Expand Down Expand Up @@ -547,6 +550,35 @@ def test_compileVariableCFF2_sparse_notdefGlyph(self, designspace):
tables=["CFF2", "hmtx", "HVAR"],
)

@pytest.mark.parametrize("compileMethod", [compileTTF, compileOTF])
@pytest.mark.parametrize("compression_level", [0, 9])
def test_compile_static_font_with_gpos_compression(
self, caplog, compileMethod, testufo, compression_level
):
with caplog.at_level(logging.INFO, logger="fontTools"):
compileMethod(testufo, ftConfig={GPOS_COMPRESSION_LEVEL: compression_level})
disabled = compression_level == 0
logged = "Compacting GPOS..." in caplog.text
assert logged ^ disabled

@pytest.mark.parametrize("compileMethod", [compileVariableTTF, compileVariableCFF2])
@pytest.mark.parametrize("variableFeatures", [True, False])
@pytest.mark.parametrize("compression_level", [0, 9])
def test_compile_variable_font_with_gpos_compression(
self, caplog, compileMethod, FontClass, variableFeatures, compression_level
):
designspace = DesignSpaceDocument.fromfile(getpath("TestVarfea.designspace"))
designspace.loadSourceFonts(FontClass)
with caplog.at_level(logging.INFO, logger="fontTools"):
compileMethod(
designspace,
ftConfig={GPOS_COMPRESSION_LEVEL: compression_level},
variableFeatures=variableFeatures,
)
disabled = compression_level == 0
logged = "Compacting GPOS..." in caplog.text
assert logged ^ disabled


if __name__ == "__main__":
sys.exit(pytest.main(sys.argv))

0 comments on commit 5b4d18f

Please sign in to comment.