Skip to content

Commit

Permalink
Avoid divzero
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarlow83 committed Nov 21, 2023
1 parent 4850f48 commit e2be457
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ocrmypdf/hocrtransform/_hocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ def _do_line_word(
self._debug_draw_space_bbox(canvas, space_box)
text.text_transform(Matrix(1, 0, 0, 1, space_box.llx, 0))
space_width = canvas.string_width(' ', fontname, fontsize)
text.horiz_scale(100 * space_box.width / space_width)
text.show(' ')
if space_width > 0:
text.horiz_scale(100 * space_box.width / space_width)
text.show(' ')

def _debug_draw_paragraph_boxes(self, canvas: Canvas, color=CYAN):
"""Draw boxes around paragraphs in the document."""
Expand Down

0 comments on commit e2be457

Please sign in to comment.