def shrink_to_fit(context, box, available_content_width):
    """Return the shrink-to-fit width of ``box``.

    *Warning:* both available_content_width and the return value are
    for width of the *content area*, not margin area.

    https://www.w3.org/TR/CSS21/visudet.html#float-width

    """
    return min(
        max(
            min_content_width(context, box, outer=False),
            available_content_width),
        max_content_width(context, box, outer=False))
Return the shrink-to-fit width of ``box``.

*Warning:* both available_content_width and the return value are
for width of the *content area*, not margin area.

https://www.w3.org/TR/CSS21/visudet.html#float-width
weasyprint/layout/preferred.py