1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
7 from gi.repository import Pango
8 from gi.repository import PangoCairo
16 @unittest.skipUnless(Pango, 'Pango not available')
17 class TestPango(unittest.TestCase):
19 def test_default_font_description(self):
20 desc = Pango.FontDescription()
21 self.assertEqual(desc.get_variant(), Pango.Variant.NORMAL)
23 def test_font_description(self):
24 desc = Pango.FontDescription('monospace')
25 self.assertEqual(desc.get_family(), 'monospace')
26 self.assertEqual(desc.get_variant(), Pango.Variant.NORMAL)
28 def test_layout(self):
29 self.assertRaises(TypeError, Pango.Layout)
30 context = Pango.Context()
31 layout = Pango.Layout(context)
32 self.assertEqual(layout.get_context(), context)
34 layout.set_markup("Foobar")
35 self.assertEqual(layout.get_text(), "Foobar")
37 def test_break_keyword_escape(self):
38 # https://bugzilla.gnome.org/show_bug.cgi?id=697363
39 self.assertTrue(hasattr(Pango, 'break_'))
40 self.assertTrue(Pango.break_ is not None)
42 def test_context_get_metrics(self):
43 # Test default "language" argument
44 font_map = PangoCairo.font_map_get_default()
45 context = font_map.create_context()
46 desc = Pango.FontDescription('monospace')
47 metrics1 = context.get_metrics(desc)
48 metrics2 = context.get_metrics(desc, context.get_language())
49 self.assertEqual(metrics1.get_ascent(), metrics2.get_ascent())