Skip to content

Commit

Permalink
Rename GlyphSets.glyph_ids to glyph_id_set
Browse files Browse the repository at this point in the history
To clarify it returns a set, not an iterator.
  • Loading branch information
kojiishi committed Jan 2, 2022
1 parent bf8b20c commit 1c1eee6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions east_asian_spacing/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions east_asian_spacing/spacing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]):
Expand Down
4 changes: 2 additions & 2 deletions tests/spacing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 1c1eee6

Please sign in to comment.