def test_sortBy_isProportional_glyphs(self): font1 = self.getFont_sortBy_monospaceGlyphs() font2 = self.getFont_sortBy_monospaceGlyphs() font3 = self.getFont_sortBy_proportionalGlyphs() font4 = self.getFont_sortBy_proportionalGlyphs() fonts = FontList() fonts.extend([font1, font2, font3, font4]) fonts.sortBy("isProportional") expected = [font3, font4, font1, font2] self.assertEqual(fonts, expected)
def test_sortBy_sortValueFunction(self): font1 = self.getFont_withGlyphCount(10) font2 = self.getFont_withGlyphCount(20) font3 = self.getFont_withGlyphCount(30) font4 = self.getFont_withGlyphCount(40) fonts = FontList() fonts.extend([font1, font2, font3, font4]) fonts.reverse() def glyphCountSortValue(font): return len(font) fonts.sortBy(glyphCountSortValue) expected = [font1, font2, font3, font4] self.assertEqual(fonts, expected)