def test_font_query_warnings(self): # Don't use BOLD as a weight font = Font() font.weight = BOLD with self.assertWarns(DeprecationWarning): query = font._make_font_query() self.assertEqual(query.get_weight(), WEIGHT_BOLD) # Don't use BOLD as a style font = Font() font.style = BOLD with self.assertWarns(DeprecationWarning): query = font._make_font_query() self.assertEqual(query.get_weight(), WEIGHT_BOLD) self.assertEqual(query.get_style(), "normal") # Don't use BOLD_ITALIC as a style font = Font() font.style = BOLD_ITALIC with self.assertWarns(DeprecationWarning): query = font._make_font_query() self.assertEqual(query.get_weight(), WEIGHT_BOLD) self.assertEqual(query.get_style(), "italic") # Ignore BOLD style if weight is not normal font = Font() font.weight = WEIGHT_LIGHT font.style = BOLD with self.assertWarns(DeprecationWarning): query = font._make_font_query() self.assertEqual(query.get_weight(), WEIGHT_LIGHT) self.assertEqual(query.get_style(), "normal") font = Font() font.weight = WEIGHT_LIGHT font.style = BOLD_ITALIC with self.assertWarns(DeprecationWarning): query = font._make_font_query() self.assertEqual(query.get_weight(), WEIGHT_LIGHT) self.assertEqual(query.get_style(), "italic")
def test_text(self): for family in [ DECORATIVE, DEFAULT, ITALIC, MODERN, ROMAN, SCRIPT, TELETYPE]: for weight in range(100, 1001, 100): for style in [NORMAL, ITALIC]: with self.subTest(family=family, weight=weight, style=style): self.gc = self.create_graphics_context() with self.draw_and_check(): font = Font(family=family) font.size = 24 font.weight = weight font.style = style self.gc.set_font(font) self.gc.set_text_position(23, 67) self.gc.show_text("hello kiva")