From 3a700901bf2508423f65d654f872cac99ce8f771 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 30 Apr 2018 23:52:52 +0200 Subject: [PATCH] Simple workaround for a dirty Pango bug Solution given by :cake: @Tontyna :cake: Fix #614, fix #585. --- weasyprint/layout/inlines.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/weasyprint/layout/inlines.py b/weasyprint/layout/inlines.py index 45814174..3e89c60d 100644 --- a/weasyprint/layout/inlines.py +++ b/weasyprint/layout/inlines.py @@ -792,10 +792,6 @@ def split_inline_box(context, box, position_x, max_x, skip_stack, # TODO: should we also accept relative children? if (child.is_in_normal_flow() and can_break_inside(child)): - # This waiting child is in flow and can be broken, - # let's break it! - break_found = True - # We break the waiting child at its last possible # breaking point. # TODO: The dirty solution chosen here is to @@ -810,6 +806,18 @@ def split_inline_box(context, box, position_x, max_x, skip_stack, absolute_boxes, fixed_boxes, line_placeholders, waiting_floats, line_children)) + + # As PangoLayout and PangoLogAttr don't always + # agree, we have to rely on the actual split to + # know whether the child was broken. + # https://github.com/Kozea/WeasyPrint/issues/614 + break_found = child_resume_at is not None + if child_resume_at is None: + # PangoLayout decided not to break the child + child_resume_at = (0, None) + # TODO: use this when Pango is always 1.40.13+: + # break_found = True + children = children + waiting_children_copy if child_new_child is None: # May be None where we have an empty TextBox.