-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
UnboundLocalError: local variable 'lower_guess' referenced before assignment #770
Comments
Unfortunately, I can't reproduce your error, I get a beautiful PDF. Do you have the problem when setting other fonts in your CSS file? |
That's interesting. The crash only triggers with It might be that the fonts themselves are broken, but even if so, that still shouldn't cause WeasyPrint to crash. |
Even with the fonts I can't reproduce. I've set Is it possible for you to edit the |
Sure, here's what I'm getting immediately before the traceback: |
Ooops, I mean |
|
Thank you. OK, we don't have a floating point rounding error, which is good news. Minimum content width is larger than maximum content width, I have to understand why. |
I'm afraid it's a duplicate of #628. You only get the problem with There IS something wrong with some MS fonts and Pango. |
I can reproduce #628 with |
Who calculates those widthes? Is this another outcome of a dissent between |
BTW: Cannot reproduce the crash, either. |
First of all, I'm not sure yet it's a duplicate of #628.
Because this use case makes the table layout crash, but #628 doesn't involve the table layout.
I have to check that. I'd love to understand what's wrong. I can't reproduce #628 on my Gentoo Linux computer but can on my Ubuntu one. I'm not able to reproduce #770 anywhere. |
@andreas-gruenbacher could you please tell what your Linux distribution is (with the version)? |
Fedora 29. WeasyPrint has been installed with |
Looks like it's something special in the 5th column, but I don't see nothing special in the 5th column |
Packages in Fedora 29 seem to be up to date, just as on my Gentoo computer. Why can't I reproduce this problem?
Neither do I. @andreas-gruenbacher One (last 😇) question: could you provide the whole traceback with the prints, so that we can know which table has the problem? |
Sure, I've already posted that in #409. |
With the |
Can anyone explain what the code below |
We have a tuple like The code only works when the tuple is sorted ( We could of course silently ignore this bug (for example, setting an original value for |
YEAH. I can reproduce the bug with Trebuchet. |
Minimal HTML sample: <table>
<th style="font-family: Trebuchet MS; white-space: nowrap">
Fahrzeug
</th>
</table> The famous mystery of the 5th column 😨… |
OK, I understand what's going on. The problem appears when two letters have a special kerning value ("Fa" here, but also crashes with famous couples like "LV", "FA", etc). |
AND OF COURSE " A". |
...and the solution is: DONT USE UPPERCASE, especially when there is a 5th column |
It seems like you're close to finding out what's causing the bug and so it can hopefully be fixed. Maybe the algorithm could be made a bit more robust to perhaps only warn when this kind of problem occurs in the future? |
Good luck @liZe! Me myself get brain damages when reading the layout source code 😏 |
It's difficult to find where the bug comes from, but I'm now 99% sure it's not a bug in WeasyPrint. The same layout created twice with the same parameters doesn't give the same result. Setting this code twice in text.py (line 987) solves the problem: layout = create_layout(
text, style, context, max_width, justification_spacing)
first_line, index = layout.get_first_line() It's probably a bug in Cairo / Pango / FontConfig / Freetype / etc. @andreas-gruenbacher Is it possible for you to give the version of these libraries on your system? |
Yes, if there's a bug in an external library, we'll have to add a workaround. |
@liZe the versions of which packages do you want to know exactly? Isn't it good enough for now that you can reproduce? I can reproduce your text.py hack from above. It also seems a bit weird that split_first_line is called six times in the minimal HTML example: with text = 'Fahrzeug ', ' Fahrzeug ', ' Fahrzeug', and then again 'Fahrzeug ', ' Fahrzeug ', ' Fahrzeug'. If I remove all the whitespace around 'Fahrzeug' in the minimal HTML example, that reduces to two calls with text = 'Fahrzeug'. |
... first result being erroneous ... minimum column widths being calculated first ... I vote for a workaround not along the lines of |
Cairo, Pango, FontConfig and Freetype. I'd like to compare with the ones on my systems to find where the bug comes from.
You can't imagine the incredible amount of work needed to find the size of cells in a table (a hint). You at least need the min-content width and the max-content width of the cell, that's why you need at least two calls. Handling white spaces also requires some work, that's why you get extra calls when there are spaces and empty lines. Of course, there are lots of "useless" function calls in WeasyPrint, but it's often hard to remove them 😄.
Of course. |
cairo-1.16.0-3.fc29.x86_64 /usr/local/lib/python3.7/site-packages/ contains the following versioned directories: |
@andreas-gruenbacher thanks a lot. I have exactly the same versions on my Gentoo box that works. Options left are font configuration and different compilation flags… |
It should be fixed now, but I really need to know the real reason for this (and fix #628). |
Almost, but the assertion below |
Fixed in 89041e8, thanks. |
This is working for now, thanks. |
Related to Kozea#770.
Version 45 ---------- Released on 2019-02-20. WeasyPrint now has a `code of conduct <https://github.com/Kozea/WeasyPrint/blob/master/CODE_OF_CONDUCT.rst>`_. A new website has been launched, with beautiful and useful graphs about speed and memory use across versions: check `WeasyPerf <https://kozea.github.io/WeasyPerf/index.html>`_. Dependencies: * Python 3.5+ is now needed, Python 3.4 is not supported anymore Bug fixes: * `798 <https://github.com/Kozea/WeasyPrint/pull/798>`_: Prevent endless loop and index out of range in pagination * `767 <https://github.com/Kozea/WeasyPrint/issues/767>`_: Add a ``--quiet`` CLI parameter * `784 <https://github.com/Kozea/WeasyPrint/pull/784>`_: Fix library loading on Alpine * `791 <https://github.com/Kozea/WeasyPrint/pull/791>`_: Use path2url in tests for Windows * `789 <https://github.com/Kozea/WeasyPrint/pull/789>`_: Add LICENSE file to distributed sources * `788 <https://github.com/Kozea/WeasyPrint/pull/788>`_: Fix pending references * `780 <https://github.com/Kozea/WeasyPrint/issues/780>`_: Don't draw patterns for empty page backgrounds * `774 <https://github.com/Kozea/WeasyPrint/issues/774>`_: Don't crash when links include quotes * `637 <https://github.com/Kozea/WeasyPrint/issues/637>`_: Fix a problem with justified text * `763 <https://github.com/Kozea/WeasyPrint/pull/763>`_: Launch tests with Python 3.7 * `704 <https://github.com/Kozea/WeasyPrint/issues/704>`_: Fix a corner case with tables * `804 <https://github.com/Kozea/WeasyPrint/pull/804>`_: Don't logger handlers defined before importing WeasyPrint * `109 <https://github.com/Kozea/WeasyPrint/issues/109>`_, `748 <https://github.com/Kozea/WeasyPrint/issues/748>`_: Don't include punctuation for hyphenation * `770 <https://github.com/Kozea/WeasyPrint/issues/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 <https://weasyprint.readthedocs.io/en/latest/tutorial.htmllogging>`_ to report the rendering process * Add a ``--debug`` CLI parameter and set debug level for unknown prefixed CSS properties * Define minimal versions of Python and setuptools in setup.cfg Documentation * `796 <https://github.com/Kozea/WeasyPrint/pull/796>`_: Fix a small typo in the tutorial * `792 <https://github.com/Kozea/WeasyPrint/pull/792>`_: Document no alignement character support * `773 <https://github.com/Kozea/WeasyPrint/pull/773>`_: Fix phrasing in Hacking section * `402 <https://github.com/Kozea/WeasyPrint/issues/402>`_: Add a paragraph about fontconfig error * `764 <https://github.com/Kozea/WeasyPrint/pull/764>`_: Fix list of dependencies for Alpine * Fix API documentation of HTML and CSS classes
I'm having issue #409 with weasyprint 44. That issue is closed and I don't see how I could reopen it. I've described what's happening in that issue for now.
The text was updated successfully, but these errors were encountered: