コード例 #1
0
    def test_layout_setting_properties():
        context = Context()
        layout = Layout(context)

        layout.set_width(300)
        assert layout.get_width() == 300

        layout.set_height(400)
        assert layout.get_height() == 400

        assert layout.get_spacing() == 0
        layout.set_spacing(30)
        assert layout.get_spacing() == 30

        layout.set_alignment(Alignment.CENTER)
        assert layout.get_alignment() is Alignment.CENTER

        layout.set_ellipsize(EllipsizeMode.MIDDLE)
        assert layout.get_ellipsize() is EllipsizeMode.MIDDLE

        ink_rect, logical_rect = layout.get_extents()
        assert logical_rect.width == 0
        assert logical_rect.height == 0

        width, height = layout.get_size()
        assert width == 0
        assert height == 0

        baseline = layout.get_baseline()
        assert baseline == 0

        line_count = layout.get_line_count()
        assert line_count == 1
コード例 #2
0
    def test_layout_iter_properties():
        context = Context()
        layout = Layout(context)
        layout_iter = layout.get_iter()

        assert layout_iter.next_run() is False
        assert layout_iter.next_char() is False
        assert layout_iter.next_cluster() is False
        assert layout_iter.next_line() is False
        assert layout_iter.at_last_line() is True
        assert layout_iter.get_index() == 0
        assert layout_iter.get_baseline() == 0

        assert isinstance(layout_iter.get_char_extents(), Rectangle)

        cluster_ink, cluster_logical = layout_iter.get_cluster_extents()
        assert isinstance(cluster_ink, Rectangle)
        assert isinstance(cluster_logical, Rectangle)

        run_ink, run_logical = layout_iter.get_run_extents()
        assert isinstance(run_ink, Rectangle)
        assert isinstance(run_logical, Rectangle)

        y0, y1 = layout_iter.get_line_yrange()
        assert y0 == 0
        assert y1 == 0

        line_ink, line_logical = layout_iter.get_line_extents()
        assert isinstance(line_ink, Rectangle)
        assert isinstance(line_logical, Rectangle)

        layout_ink, layout_logical = layout_iter.get_layout_extents()
        assert isinstance(layout_ink, Rectangle)
        assert isinstance(layout_logical, Rectangle)
コード例 #3
0
    def test_layout_setting_text():
        context = Context()
        layout = Layout(context)

        layout.set_width(300)

        layout.set_text('Hi from Pango')
        layout.set_markup('<span font="italic 30">Hi from Παν語</span>')
コード例 #4
0
    def test_context_properties(self):
        context = Context()

        desc = FontDescription()
        desc.set_family('sans-serif')
        context.set_font_description(desc)
        assert context.get_font_description().get_family() == 'sans-serif'

        context.set_base_gravity(Gravity.EAST)
        assert context.get_base_gravity() == Gravity.EAST
        assert context.get_gravity() == Gravity.EAST

        context.set_gravity_hint(GravityHint.STRONG)
        assert context.get_gravity_hint() == GravityHint.STRONG
コード例 #5
0
ファイル: test_layout.py プロジェクト: leifgehrmann/pangocffi
    def test_set_attributes(self):
        context = Context()
        layout = Layout(context)
        layout.set_text("Working?")
        attr = Attribute.from_size(5, 1, 4)
        attr_list = AttrList()

        attr_list.insert(attr)

        layout.set_attributes(attr_list)
        layout.get_attributes()

        # Resetting the attributes
        layout.set_attributes(None)
        layout.get_attributes()
コード例 #6
0
    def test_layout_setting_font_description():
        context = Context()
        layout = Layout(context)

        # Assert that the font description is not set
        assert layout.get_font_description() is None

        # Creating the font description
        desc = FontDescription()
        desc.set_family('sans-serif')
        layout.set_font_description(desc)

        # Verifying the font description was set
        same_desc = layout.get_font_description()
        assert same_desc.get_family() == desc.get_family()

        # Changing the font description
        desc.set_family('serif')
        assert same_desc.get_family() != desc.get_family()

        # Resetting the font description
        layout.set_font_description(None)
        assert layout.get_font_description() is None
コード例 #7
0
 def test_layout_returns_identical_context():
     context = Context()
     layout = Layout(context)
     identical_context = layout.get_context()
     assert identical_context.get_pointer() == context.get_pointer()
コード例 #8
0
 def test_layout_not_implemented_equality(self):
     context = Context()
     layout = Layout(context)
     assert ('not an object' != layout)
コード例 #9
0
 def test_layout_get_pointer_returns_identical_layout():
     context = Context()
     layout = Layout(context)
     identical_layout = Layout.from_pointer(layout.get_pointer())
     assert identical_layout.get_pointer() == layout.get_pointer()
コード例 #10
0
 def test_context_init_identical_context(self):
     context = Context()
     identical_context = Context.from_pointer(context.get_pointer())
     assert identical_context == context
コード例 #11
0
 def test_layout_iter_pointer():
     context = Context()
     layout = Layout(context)
     layout_iter = layout.get_iter()
     assert isinstance(layout_iter.get_pointer(), ffi.CData)
コード例 #12
0
    def test_layout_iterator_run_returns_none():
        context = Context()
        layout = Layout(context)
        layout_iter = layout.get_iter()

        assert layout_iter.get_run() is None