From 1c1eee608a02ba24f9b6c2d70e3fb23cd51aa8ee Mon Sep 17 00:00:00 2001 From: Koji Ishii Date: Mon, 3 Jan 2022 01:11:37 +0900 Subject: [PATCH] Rename `GlyphSets.glyph_ids` to `glyph_id_set` To clarify it returns a set, not an iterator. --- east_asian_spacing/builder.py | 4 ++-- east_asian_spacing/spacing.py | 5 +++-- tests/spacing_test.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/east_asian_spacing/builder.py b/east_asian_spacing/builder.py index 906791b..a9543d4 100755 --- a/east_asian_spacing/builder.py +++ b/east_asian_spacing/builder.py @@ -188,8 +188,8 @@ def _testers(self): for font in spacing.changed_fonts: tester = EastAsianSpacingTester( font, - glyphs=spacing.horizontal.glyph_ids, - vertical_glyphs=spacing.vertical.glyph_ids) + glyphs=spacing.horizontal.glyph_id_set, + vertical_glyphs=spacing.vertical.glyph_id_set) yield tester async def test(self, config=None, smoke=None): diff --git a/east_asian_spacing/spacing.py b/east_asian_spacing/spacing.py index 4ad647d..b15f98d 100755 --- a/east_asian_spacing/spacing.py +++ b/east_asian_spacing/spacing.py @@ -9,6 +9,7 @@ from typing import List from typing import Optional from typing import Tuple +from typing import Set from fontTools.otlLib.builder import buildValue from fontTools.otlLib.builder import ChainContextPosBuilder @@ -70,7 +71,7 @@ def _name_and_glyph_data_lists(self): ('middle', self.middle), ('space', self.space)) @property - def glyph_ids(self): + def glyph_id_set(self) -> Set[int]: glyph_ids = set() for glyph_data_set in self._glyph_data_lists: glyph_ids |= glyph_data_set.glyph_id_set @@ -129,7 +130,7 @@ def str_from_glyph_id(glyph_id): if glyphs_by_glyph_id: output.write(f'# {prefix}filtered\n') - glyph_ids = self.glyph_ids + glyph_ids = self.glyph_id_set for glyph_id, glyph_data_list in sorted( glyphs_by_glyph_id.items(), key=lambda key_value: key_value[0]): diff --git a/tests/spacing_test.py b/tests/spacing_test.py index 8a0cdd9..2679e05 100644 --- a/tests/spacing_test.py +++ b/tests/spacing_test.py @@ -13,11 +13,11 @@ def test_cache(test_font_path): g4 = GlyphData(4, 0, 0, 0) trio = GlyphSets(GlyphDataList([g1]), GlyphDataList([g2]), GlyphDataList([g3])) - assert trio.glyph_ids == {1, 2, 3} + assert trio.glyph_id_set == {1, 2, 3} trio.add_to_cache(font) trio2 = GlyphSets() glyphs = trio2.add_from_cache(font, [g1, g2, g3, g4]) - assert trio2.glyph_ids == {1, 2, 3} + assert trio2.glyph_id_set == {1, 2, 3} assert list(trio2.left.glyph_ids) == [1] assert list(trio2.right.glyph_ids) == [2] assert list(trio2.middle.glyph_ids) == [3]