Skip to content
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

Fix the line breaking algorithm #528

Merged
merged 7 commits into from
Nov 16, 2017
Merged

Fix the line breaking algorithm #528

merged 7 commits into from
Nov 16, 2017

Conversation

liZe
Copy link
Member

@liZe liZe commented Oct 24, 2017

Close #301.

I was wrong about so many things.

  • The line breaking algorithm is really well defined in the Text 3 module. It does not rely on fragmentation, that's so cool. Most of the rules were already supported, the spec mainly relies on the "soft wrap opportunities" that's not defined in the spec, but…

  • This "soft wrap opportunities" thing is very, very well supported by Pango. As for everyting around Unicode, I thought that it was complicated, and it is actually really more complicated than just complicated. Did I want to rewrite this? OMG, I was crazy. But…

  • After reading the current code, the only real missing feature to cleanly support line breaking was to remove the soft wrap opportunities at tags boundaries. And that's all. Pango is incredible to cut lines, it just doesn't know specific CSS rules (as space trimming and stripping), but we don't care. We can imagine workarounds in WeasyPrint, that's not bad, everybody does that (except "real" browsers that can hire Behdad to rewrite Pango for their needs). And…

  • We already have the workarounds. We don't have to rewrite the line breaking algorithm, because Pango + workarounds is actually a really smart way to do what we want to do. There's no important thing to add, except from cleaning some complicated *-wrap and *-break attributes and from line-breaks at tags boundaries. And…

  • Line-breaks at tags boundaries are now correctly supported. That's what this PR is about. That's all, and that was pretty easy. And…

  • Let's talk about right-to-left and bidi. Let's talk about RTL support #106. Pango already handles this in text. I'm now sure that we can handle this for boxes, thanks to some features Pango will provide, and a lot of tests. Thanks to the W3C, we already have tests. So… Let's go!

@liZe liZe added this to the v0.42 milestone Nov 16, 2017
@liZe liZe merged commit 4e3cfb5 into master Nov 16, 2017
@liZe liZe deleted the text branch November 16, 2017 16:37
@liZe liZe mentioned this pull request Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant