def test_fallback_font_if_required_valid_font(self):
     svg = os.path.join(BASE_PATH, "basic.svg")
     image = Image.new("RGB", (1000, 1000))
     tbd = TextBoxDrawer(image, None, svg)
     font_path = "static/fonts/PatrickHand-Regular.ttf"
     font = tbd.fallback_font_if_required(font_path, "abc")
     self.assertEqual(font_path, font)
 def test_fallback_font_if_required_ordinal_too_high(self):
     svg = os.path.join(BASE_PATH, "basic.svg")
     image = Image.new("RGB", (1000, 1000))
     tbd = TextBoxDrawer(image, None, svg)
     font_path = "static/fonts/PatrickHand-Regular.ttf"
     new_font_path = tbd.fallback_font_if_required(font_path, chr(300))
     self.assertNotEqual(font_path, new_font_path)
     self.assertEqual(DEFAULT_FONT, new_font_path)
 def test_fallback_font_none_given(self):
     svg = os.path.join(BASE_PATH, "basic.svg")
     image = Image.new("RGB", (1000, 1000))
     tbd = TextBoxDrawer(image, None, svg)
     font_path = tbd.fallback_font_if_required(None, "abc")
     self.assertEqual(DEFAULT_FONT, font_path)