-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "overflow-wrap: anywhere" #1520
Conversation
This supports the `overflow-wrap` value `anywhere`: `anywhere` is like `break-word`, but the soft breaks it allows *are* considered when calculating min-content intrinsic sizes.
Hello @aschmitz, Thanks a lot for this pull request, it’s just perfect 💜.
That’s a good question. We’ll check that and find why we get 100. |
The problem is caused by the trailing space whose size is removed from the minimum width. Looks like it’s removed twice :/. I’ll remove the trailing space from the test, and add another test to check what’s wrong with it. |
Moreover, the first test doesn’t pass with Pango 1.50.x. We already had to report a bug with tabs, let’s hope that this bug is also easy to reproduce and to fix… |
That’s actually a bug in Pango 1.48.x, fixed in 1.50.x. The problem is caused by hyphens, automatically added when words are broken. With Pango 1.48.x, when the
Notice the missing hyphen on the first line. As, in WeasyPrint, we render lines one by one, the hyphen was always missing. That’s why we got a width of 1 character. Now, in Pango 1.50.x, we get:
That’s better! But the minimum width is then 2 characters. The solution is to simply disable hyphenation when we break words. |
When we calculate the minimum width of an inline block, the size of the trailing space is already removed by split_first_line. There’s no need to remove it twice. We should probably fix split_first_line to remove the trailing space only when it’s been asked to. But there’s no obvious situation when we want the minimum width to include trailing spaces, as the minimum size requires line breaks everywhere, including after each space. At least, this commit doesn’t remove trailing spaces twice. Related to #1520.
The trailing space bug is now fixed. As far as I can tell, |
There are two cases where this is a concern, and I mostly have to handle in advance without knowing which one I'm going to be hitting:
Unfortunately I have no real way to know which is which upfront, since my users provide arbitrary content. I could set a minimum width for columns across the board, but that feels like a bit of a hack as well. However, I can detect a long string that wouldn't otherwise wrap, and automatically enclose it with something like (Of course the "real" solution is having people specify column widths if necessary, which we also support, but it would be very nice to not require everyone to do that in common cases.) |
I agree, But, by "
That would be the easiest way to handle long strings. Hyphenation is a nice solution for real words, but it’s quite useless for URLs for example. |
Yep, you're right. I was misinterpreting that as |
This supports the
overflow-wrap
valueanywhere
:anywhere
is likebreak-word
, but the soft breaks it allows are considered when calculating min-content intrinsic sizes.This can help alleviate the problems identified in #1153 (comment), but obviously doesn't close that issue.
I'm a little unsure on the test: if you have preferred ways to test this behavior, feel free to remove these tests. (Additionally, the
break-word
andnormal
tests would seem as though they should be 120px wide, not 100, but I can't figure out why they have their current values: I'd be interested in thoughts there.