Пример #1
0
 def test_should_parse_font_name_with_all_possible_variants_if_no_variant_defined(
         self):
     d = FontDeclaration.parse('Abel')
     self.assertEqual('Abel', d.font_name)
     self.assertEqual([
         '100', '100i', '200', '200i', '300', '300i', '400', '400i', '500',
         '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i'
     ], d.variants_display)
Пример #2
0
 def get_font_declaration(cls, declaration):
     """
     Return the font name and variant information from the given font
     declaration as it would be defined for RESOURCES.
     Format:
       <font_name> [:<variant-selector>,...]
     Examples:
       Open Sans :300,300i
       Abel :400
     """
     return FontDeclaration.parse(declaration)
Пример #3
0
 def test_should_join_variants_of_given_declaration(self):
     d = FontDeclaration.parse('Abel:300')
     d.join_with(FontDeclaration.parse('Abel:300i'))
     self.assertEqual('Abel', d.font_name)
     self.assertEqual(['300', '300i'], d.variants_display)
Пример #4
0
 def test_should_return_none_if_empty_string(self):
     d = FontDeclaration.parse('')
     self.assertIsNone(d)
Пример #5
0
 def test_should_accept_white_space(self):
     d = FontDeclaration.parse('  Open Sans  : 300, 300i,   400, 400i')
     self.assertEqual('Open Sans', d.font_name)
     self.assertEqual(['300', '300i', '400', '400i'], d.variants_display)
Пример #6
0
 def test_should_ignore_duplicates(self):
     d = FontDeclaration.parse('Open Sans:300,300,400i,400i')
     self.assertEqual('Open Sans', d.font_name)
     self.assertEqual(['300', '400i'], d.variants_display)
Пример #7
0
 def test_should_parse_font_name_with_variants(self):
     d = FontDeclaration.parse('Open Sans:400,300,300i')
     self.assertEqual('Open Sans', d.font_name)
     self.assertEqual(['400', '300', '300i'], d.variants_display)
Пример #8
0
 def test_should_create_font_declaration_with_given_font_name_and_list_of_variants(
         self):
     d = FontDeclaration('Abel', [])
     self.assertEqual('Abel', d.font_name)
     self.assertEqual([], d.variants)
Пример #9
0
 def test_should_not_add_existing_variant(self):
     d = FontDeclaration.parse('Abel:300')
     d.add_variant(FontVariant('300', 'normal'))
     self.assertEqual(['300'], d.variants_display)
Пример #10
0
 def test_should_add_new_variant(self):
     d = FontDeclaration.parse('Abel:300')
     d.add_variant(FontVariant('300', 'italic'))
     self.assertEqual(['300', '300i'], d.variants_display)
Пример #11
0
 def test_should_return_false_if_variant_is_not_supported(self):
     d = FontDeclaration.parse('Abel:300,400i')
     self.assertFalse(d.supports_variant_by_components('300', 'italic'))
     self.assertFalse(d.supports_variant_by_components('400', 'normal'))
Пример #12
0
 def test_should_return_true_if_variant_is_supported(self):
     d = FontDeclaration.parse('Abel:300,400i')
     self.assertTrue(d.supports_variant_by_components('400', 'italic'))
Пример #13
0
 def test_should_only_join_same_font(self):
     d = FontDeclaration.parse('Abel:300')
     d.join_with(FontDeclaration.parse('Open Sans:300i'))
     self.assertEqual('Abel', d.font_name)
     self.assertEqual(['300'], d.variants_display)
Пример #14
0
 def test_should_not_yield_duplicates(self):
     d = FontDeclaration.parse('Abel:300')
     d.join_with(FontDeclaration.parse('Abel:300'))
     self.assertEqual('Abel', d.font_name)
     self.assertEqual(['300'], d.variants_display)
Пример #15
0
 def mocked_font_declarations():
     return [FontDeclaration.parse('Foo:300')]