From 74253e5fc8e5a3ebc99f49b77721f718b52b2e44 Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Wed, 11 Dec 2024 16:23:45 +0100 Subject: [PATCH] hocr: only add space if boxwidth is positive --- src/ocrmypdf/hocrtransform/_hocr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ocrmypdf/hocrtransform/_hocr.py b/src/ocrmypdf/hocrtransform/_hocr.py index fd4dfe9b5..8c16cbde2 100644 --- a/src/ocrmypdf/hocrtransform/_hocr.py +++ b/src/ocrmypdf/hocrtransform/_hocr.py @@ -409,7 +409,7 @@ def _do_line_word( space_box = Rectangle(next_box.urx, box.lly, box.llx, next_box.ury) self._debug_draw_space_bbox(canvas, space_box) space_width = self._font.text_width(' ', fontsize) - if space_width > 0: + if space_width > 0 and space_box.width > 0: if text_direction == TextDirection.LTR: text.text_transform(Matrix(1, 0, 0, -1, space_box.llx, 0)) elif text_direction == TextDirection.RTL: