File: test_layout.py

package info (click to toggle)
pyglet 1.5.27%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,356 kB
  • sloc: python: 98,028; ansic: 171; makefile: 148; sh: 9
file content (19 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pyglet

def test_incrementallayout_get_position_on_line_before_start_of_text():
    single_line_text = "This is a single line of text."
    document = pyglet.text.document.UnformattedDocument(single_line_text)
    font = document.get_font()
    layout = pyglet.text.layout.IncrementalTextLayout(document,
                                                      height = font.ascent - font.descent,
                                                      width = 200,
                                                      multiline=False)
    layout.x = 100
    layout.y = 100

    assert layout.get_position_on_line(0, 100) == 0
    assert layout.get_position_on_line(0, 90) == 0
    assert layout.get_position_on_line(0, 80) == 0
    assert layout.get_position_on_line(0, 70) == 0
    assert layout.get_position_on_line(0, 60) == 0
    assert layout.get_position_on_line(0, 50) == 0