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

Problem with justify text and comma in end of line #637

manuthema opened this issue Jun 8, 2018 · 4 comments

Problem with justify text and comma in end of line #637

manuthema opened this issue Jun 8, 2018 · 4 comments


Copy link

@manuthema manuthema commented Jun 8, 2018

Sometimes with justified text, the spaces between words are not well calculated and there is a space at the end of the line. This occurs when the line break coincides between a word and a comma. Previously (weasyprint 0.36) it happened that separated the comma from the word

I attach the minimum html with which I have been able to reproduce the problem.

I have the following versions:
weasyprint: 0.42.3
pango: 1.42.01

texto justificado


@liZe liZe added the bug label Jun 8, 2018
Copy link

@Tontyna Tontyna commented Jun 16, 2018

I do understand what happens and what goes wrong but I'm unable to spot the place in source where to fix it. Ok, what happens:

The justify-me-text-block ist split into LineBoxes -- get_next_linebox calls split_inline_box etc.
The width of the individual LineBoxes is calculated in split_inline_box according to the text they contain.
This width should be the width of the line when left-aligned.

Via text_align justified lines then get some additional space inserted between their words. The space to insert is calculated as the differenence between the line's width and the available width.
This works fine as long as the given line width is correct.

In the case of the faulty aligned line split_inline_box has decided that the last bold BLA fits on the line and calculates a line-width including this BLA.
In the further processing the following comma wants to stick with the BLA and forces it onto the next line.
(I can see, that the comma would fit, too, on the previous line, but that's another story.)

In any case, problem and source of mis-justification is: The width of the LineBox from which the BLA was removed, is not updated. And text_align, not being informed about the shrinking, inserts almost no space at all between the words, an thats it.

I myself cannot find the place in source where to fix that. The layout-code muddles my brain...

Copy link

@jiro412j jiro412j commented Jul 2, 2018

I also experience the same problem
weasyprint: 0.42.3
pango: 1.42.01


Copy link

@liZe liZe commented Jan 21, 2019

Minimal use case:

<p style="text-align: justify; font-family: ahem; background-color: yellow; width: 7em">
a b <span>bla</span>,
@liZe liZe closed this in f67b7a6 Jan 21, 2019
@liZe liZe added this to the 45 milestone Jan 21, 2019
Copy link

@liZe liZe commented Jan 21, 2019

The layout-code muddles my brain...

split_inline_box is a nightmare that I should rewrite.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 21, 2019
Version 45

Released on 2019-02-20.

WeasyPrint now has a `code of conduct

A new website has been launched, with beautiful and useful graphs about speed
and memory use across versions: check `WeasyPerf


* Python 3.5+ is now needed, Python 3.4 is not supported anymore

Bug fixes:

* `798 <>`_:
  Prevent endless loop and index out of range in pagination
* `767 <>`_:
  Add a ``--quiet`` CLI parameter
* `784 <>`_:
  Fix library loading on Alpine
* `791 <>`_:
  Use path2url in tests for Windows
* `789 <>`_:
  Add LICENSE file to distributed sources
* `788 <>`_:
  Fix pending references
* `780 <>`_:
  Don't draw patterns for empty page backgrounds
* `774 <>`_:
  Don't crash when links include quotes
* `637 <>`_:
  Fix a problem with justified text
* `763 <>`_:
  Launch tests with Python 3.7
* `704 <>`_:
  Fix a corner case with tables
* `804 <>`_:
  Don't logger handlers defined before importing WeasyPrint
* `109 <>`_,
  `748 <>`_:
  Don't include punctuation for hyphenation
* `770 <>`_:
  Don't crash when people use uppercase words from old-fashioned Microsoft
  fonts in tables, especially when there's an 5th column
* Use a `separate logger
  <>`_ to
  report the rendering process
* Add a ``--debug`` CLI parameter and set debug level for unknown prefixed CSS
* Define minimal versions of Python and setuptools in setup.cfg


* `796 <>`_:
  Fix a small typo in the tutorial
* `792 <>`_:
  Document no alignement character support
* `773 <>`_:
  Fix phrasing in Hacking section
* `402 <>`_:
  Add a paragraph about fontconfig error
* `764 <>`_:
  Fix list of dependencies for Alpine
* Fix API documentation of HTML and CSS classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants