Esempio n. 1
0
 def getFonts_sortBy(self, attr, values):
     fonts = FontList()
     for value in values:
         font = self.getFont()
         setattr(font.info, attr, value)
         if attr != "familyName":
             font.info.familyName = "%s %s" % (attr, repr(value))
         fonts.append(font)
     return fonts
Esempio n. 2
0
 def getFonts_sortBy(self, attr, values):
     fonts = FontList()
     for value in values:
         font = self.getFont()
         setattr(font.info, attr, value)
         if attr != "familyName":
             font.info.familyName = "%s %s" % (attr, repr(value))
         fonts.append(font)
     return fonts
Esempio n. 3
0
 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)
Esempio n. 4
0
 def test_getFontsByStyleName(self):
     font1 = self.getFont()
     font1.info.styleName = "A"
     font2 = self.getFont()
     font2.info.styleName = "B"
     font3 = self.getFont()
     font3.info.styleName = "C"
     font4 = self.getFont()
     font4.info.styleName = "A"
     fonts = FontList()
     fonts.extend([font1, font2, font3, font4])
     found = fonts.getFontsByStyleName("A")
     self.assertEqual(found, [font1, font4])
Esempio n. 5
0
 def test_getFontsByStyleName(self):
     font1 = self.getFont()
     font1.info.styleName = "A"
     font2 = self.getFont()
     font2.info.styleName = "B"
     font3 = self.getFont()
     font3.info.styleName = "C"
     font4 = self.getFont()
     font4.info.styleName = "A"
     fonts = FontList()
     fonts.extend([font1, font2, font3, font4])
     found = fonts.getFontsByStyleName("A")
     self.assertEqual(found, [font1, font4])
Esempio n. 6
0
 def test_sortBy_isMonospace_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.reverse()
     fonts.sortBy("isMonospace")
     expected = [font2, font1, font4, font3]
     self.assertEqual(fonts, expected)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)