Fix floating-point number error to fix floating box layout

Fix #583.
This commit is contained in:
Guillaume Ayoub 2018-03-22 02:00:17 +01:00
parent a859d8d599
commit 4e1fad39dc
1 changed files with 4 additions and 0 deletions

View File

@ -132,6 +132,10 @@ def get_next_linebox(context, linebox, position_y, skip_stack,
line.margin_bottom = 0
line.translate(offset_x, offset_y)
# Avoid floating point errors, as position_y - top + top != position_y
# Removing this line breaks the position == linebox.position test below
# See https://github.com/Kozea/WeasyPrint/issues/583
line.position_y = position_y
if line.height <= candidate_height:
break