fixed issue with bounding box height being wrong
Python CI / test (3.10) (push) Has been cancelled
Python CI / test (3.12) (push) Has been cancelled
Python CI / test (3.13) (push) Has been cancelled

This commit is contained in:
2025-11-09 17:10:50 +01:00
parent 56c2c21021
commit 50b9aa5431
4 changed files with 56 additions and 13 deletions
+17 -8
View File
@@ -145,7 +145,9 @@ class TestTextQueryPoint(unittest.TestCase):
text.set_origin(np.array([100, 100]))
# Point inside text bounds
self.assertTrue(text.in_object(np.array([110, 105])))
# Origin is at baseline (100, 100), so test a point slightly above (at ascent/2)
# and to the right
self.assertTrue(text.in_object(np.array([110, 100])))
def test_in_object_miss(self):
"""Test in_object returns False for point outside text"""
@@ -188,7 +190,9 @@ class TestLineQueryPoint(unittest.TestCase):
# (after rendering, text objects have positions set)
if len(line._text_objects) > 0:
text_obj = line._text_objects[0]
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1] + 5))
# Origin is at baseline, so query at baseline position (Y = origin[1])
# with X offset into the text
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1]))
result = line.query_point(point)
@@ -234,7 +238,8 @@ class TestLineQueryPoint(unittest.TestCase):
# Query the link
if len(line._text_objects) > 0:
text_obj = line._text_objects[0]
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1] + 5))
# Origin is at baseline, query at baseline Y position
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1]))
result = line.query_point(point)
@@ -279,7 +284,8 @@ class TestPageQueryPoint(unittest.TestCase):
# Query a point inside the line
if len(line._text_objects) > 0:
text_obj = line._text_objects[0]
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1] + 5))
# Origin is at baseline, query at baseline Y position
point = (int(text_obj._origin[0] + 5), int(text_obj._origin[1]))
result = self.page.query_point(point)
@@ -321,7 +327,8 @@ class TestPageQueryPoint(unittest.TestCase):
# Query first line
if len(line1._text_objects) > 0:
text_obj1 = line1._text_objects[0]
point1 = (int(text_obj1._origin[0] + 5), int(text_obj1._origin[1] + 5))
# Origin is at baseline, query at baseline Y position
point1 = (int(text_obj1._origin[0] + 5), int(text_obj1._origin[1]))
result1 = self.page.query_point(point1)
self.assertIsNotNone(result1)
@@ -330,7 +337,8 @@ class TestPageQueryPoint(unittest.TestCase):
# Query second line
if len(line2._text_objects) > 0:
text_obj2 = line2._text_objects[0]
point2 = (int(text_obj2._origin[0] + 5), int(text_obj2._origin[1] + 5))
# Origin is at baseline, query at baseline Y position
point2 = (int(text_obj2._origin[0] + 5), int(text_obj2._origin[1]))
result2 = self.page.query_point(point2)
self.assertIsNotNone(result2)
@@ -368,9 +376,10 @@ class TestPageQueryRange(unittest.TestCase):
start_text = line._text_objects[0]
end_text = line._text_objects[1]
# Origin is at baseline, query at baseline Y position
start_point = (
int(start_text._origin[0] + 5), int(start_text._origin[1] + 5))
end_point = (int(end_text._origin[0] + 5), int(end_text._origin[1] + 5))
int(start_text._origin[0] + 5), int(start_text._origin[1]))
end_point = (int(end_text._origin[0] + 5), int(end_text._origin[1]))
sel_range = self.page.query_range(start_point, end_point)