diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index 4cfe23e3..22fb3cb7 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -255,7 +255,8 @@ def inline_line_widths(context, box, outer, is_line_start, minimum, _, _, new_resume_at, width, _, _ = ( text.split_first_line( child_text[resume_at:], child.style, context, - max_width, child.justification_spacing)) + max_width, child.justification_spacing, + minimum=True)) lines.append(width) if first_line: break diff --git a/weasyprint/text.py b/weasyprint/text.py index d49aff86..6e8a7c97 100644 --- a/weasyprint/text.py +++ b/weasyprint/text.py @@ -915,7 +915,8 @@ def create_layout(text, style, context, max_width, justification_spacing): return layout -def split_first_line(text, style, context, max_width, justification_spacing): +def split_first_line(text, style, context, max_width, justification_spacing, + minimum=False): """Fit as much as possible in the available width for one line of text. Return ``(layout, length, resume_at, width, height, baseline)``. @@ -1127,7 +1128,7 @@ def split_first_line(text, style, context, max_width, justification_spacing): first_line_width, _ = get_size(first_line, style) space = max_width - first_line_width # If we can break words and the first line is too long - if overflow_wrap == 'break-word' and space < 0: + if not minimum and overflow_wrap == 'break-word' and space < 0: # Is it really OK to remove hyphenation for word-break ? hyphenated = False # TODO: Modify code to preserve W3C condition: