WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Hyphenation not working when a nbsp is present elsewhere in the word

Open ondras opened this issue 1 year ago • 1 comments

I am not sure whether this is a bug or feature. See this rendering:

image

The "x komunikace" is not hyphenated when the space is non-breakable. I would say that it is a bug, because browsers line-break both cases in the same fashion.

ondras avatar Oct 07 '24 12:10 ondras

I might have fixed this in a PR: https://github.com/Kozea/WeasyPrint/pull/2271

(I have absolutely zero experience with Pango and the underlying line-breaking algorithm in line_break.py is very complex, so please double-check my code.)

ondras avatar Oct 07 '24 20:10 ondras

Here’s what I get with various browsers. Firefox seems to be the only one to do things right.

Chrome: Image

Firefox: Image

Gnome Web: Image

Here’s what I get with WeasyPrint: Image

WeasyPrint can break the first word correctly, but not the second one.

liZe avatar Oct 25 '24 08:10 liZe

Right. The issue is visible when the hyphenation opportunity is in the second word (of the nbsp-joined word pair). This is very typical for Czech typography, where we join a one-letter word with the (longer) following word using a nbsp (as seen in my first post).

ondras avatar Oct 25 '24 08:10 ondras