#2946·WeasyPrint

Inline-block with surrounding whitespace wraps its last word since 70.0 (Pango < 1.52)

Author: WilmaWinkelmannCreated Sep 29, 2026Updated Sep 29, 2026

Since 70.0, an inline-block whose text has surrounding whitespace wraps its last word, even though the box is sized to fit it:

xml
<div style="display: inline-block">
  Total Financed
</div>

69.0 renders "Total Financed" on one line. 70.0 renders "Total" and "Financed" on two lines. It happens with Pango 1.50 (Debian 12, Ubuntu 22.04) but not with Pango 1.52 or later, which is probably why the tests don't catch it. test_breaking_linebox_regression_13 fails on main with Pango 1.50 for the same reason.

I bisected it to 148bc049a8 (the fix for #2614). As far as I can tell, step 2 of split_first_line measures the line including its trailing collapsible space, so a line that fits without the space is considered too wide and gets split in step 3. Before #2614, step 3 happened to miss the next word, so the problem was hidden.

In our case it changes the layout of most generated invoices and letters. Where the box can't grow, the wrapped line is printed over the next one.

I have a small fix that ignores hanging trailing spaces in that check, with a test: https://github.com/WilmaWinkelmann/WeasyPrint/compare/main...WilmaWinkelmann:fix-trailing-space-fit. With Pango 1.50 it makes regression_13 pass and adds no failures; with Pango 1.56 the suite stays green. I'm happy to open a pull request if you want it.