def create_layout(text, style, context, max_width, justification_spacing):
    """Return an opaque Pango layout with default Pango line-breaks."""
    layout = Layout(context, style, justification_spacing, max_width)

    # Make sure that max_width * Pango.SCALE == max_width * 1024 fits in a
    # signed integer. Treat bigger values same as None: unconstrained width.
    text_wrap = style['white_space'] in ('normal', 'pre-wrap', 'pre-line')
    if max_width is not None and text_wrap and max_width < 2 ** 21:
        pango.pango_layout_set_width(layout.layout, int(max(0, max_width) * TO_UNITS))

    layout.set_text(text)
    return layout
Return an opaque Pango layout with default Pango line-breaks.
weasyprint/text/line_break.py