xref: /aosp_15_r20/external/fonttools/Tests/ttLib/ttCollection_test.py (revision e1fe3e4ad2793916b15cccdc4a7da52a7e1dd0e9)
1import os
2from pathlib import Path
3from fontTools.ttLib import TTCollection
4import pytest
5
6TTX_DATA_DIR = Path(__file__).parent.parent / "ttx" / "data"
7
8
9@pytest.fixture(params=[None, True, False])
10def lazy(request):
11    return request.param
12
13
14def test_lazy_open_path(lazy):
15    ttc_path = TTX_DATA_DIR / "TestTTC.ttc"
16    with TTCollection(ttc_path, lazy=lazy) as collection:
17        assert len(collection) == 2
18        assert collection[0]["maxp"].numGlyphs == 6
19        assert collection[1]["maxp"].numGlyphs == 6
20
21
22def test_lazy_open_file(lazy):
23    with (TTX_DATA_DIR / "TestTTC.ttc").open("rb") as file:
24        collection = TTCollection(file, lazy=lazy)
25        assert len(collection) == 2
26        assert collection[0]["maxp"].numGlyphs == 6
27        assert collection[1]["maxp"].numGlyphs == 6
28