New PDF engine: Ignore dive by zero when average char width is zero

This commit is contained in:
Kovid Goyal 2024-10-24 22:08:30 +05:30
parent 59661ebb28
commit c1c8a81227
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -990,7 +990,10 @@ class Page:
frag.indented = 1 # 1em frag.indented = 1 # 1em
else: # Assume left margin of approx = number of chars else: # Assume left margin of approx = number of chars
# Should check for values approx the same, as with indents # Should check for values approx the same, as with indents
try:
frag.margin_left = int(round((frag.left - left) / frag.average_character_width)+0.5) frag.margin_left = int(round((frag.left - left) / frag.average_character_width)+0.5)
except ZeroDivisionError:
frag.margin_left = 0
if last_frag is not None \ if last_frag is not None \
and frag.bottom - last_frag.bottom \ and frag.bottom - last_frag.bottom \
> stats.para_space*SECTION_FACTOR: > stats.para_space*SECTION_FACTOR: