| 1 | import pyglet |
| 2 | import pyglet.text.layout |
| 3 | |
| 4 | |
| 5 | def test_incrementallayout_get_position_on_line_before_start_of_text(): |
| 6 | single_line_text = "This is a single line of text." |
| 7 | document = pyglet.text.document.UnformattedDocument(single_line_text) |
| 8 | font = document.get_font() |
| 9 | layout = pyglet.text.layout.IncrementalTextLayout(document, |
| 10 | height = font.ascent - font.descent, |
| 11 | width = 200, |
| 12 | multiline=False) |
| 13 | layout.x = 100 |
| 14 | layout.y = 100 |
| 15 | |
| 16 | assert layout.get_position_on_line(0, 100) == 0 |
| 17 | assert layout.get_position_on_line(0, 90) == 0 |
| 18 | assert layout.get_position_on_line(0, 80) == 0 |
| 19 | assert layout.get_position_on_line(0, 70) == 0 |
| 20 | assert layout.get_position_on_line(0, 60) == 0 |
| 21 | assert layout.get_position_on_line(0, 50) == 0 |