Just as it's done in inline_min_content_width, the first_line attribute is now
used in inline_line_widths. It greatly improves performance for really long
texts.
Style is not copied anymore when boxes are duplicated. Style dicts are not
modified anymore during the layout, as it was before for some properties:
- margins, borders and paddings when the box was split between two
pages (useless as these computed values are stored directly in the box),
- top borders were changed in tables (useless for the same reason),
- bookmark labels and string sets are now stored in the box.
This commit can introduce very subtle bugs that are hard to debug. In the
future, we should try to freeze the style dicts before the layout.
Related to #70.
The hack had been added to remove extra line breaks caused by floating point
errors when the shrink-to-fit width was coming from Pango and had a slightly
higher value when re-calculated in split_first_line.
The same problem appears when we split a line contaning inline-blocks (instead
of letters in the previous case), as the shrink-to-fit width may also inderctly
come from Pango and hit the same re-calculation floating point errors.
This commit moves the hack at a higher level, increasing the max width before
calling split_first_line when the line contains letters (same result as
before), but also before splitting lines containing inline-blocks.
Fix#467.
When tests are launched with "./setup.py test" and pytest is not installed on
the system, pytest is installed by setup.py and isort fails to find where
it comes from.
Fix#437.
Backward-incompatible change: the signature of weasyprint.urls.url_join has
changed to allow relative links without a base URI.
This feature doesn't look really safe at first sight, but I can't find
anything bad coming from these changes. If there's a bug, I take the blame.
Traceback (most recent call last):
[...]
File "/app/env/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 718, in split_text_box
'Expected nothing or a preserved line break' % (between,))
AssertionError: Got '1,' between two lines. Expected nothing or a preserved line break
The Assertion Error can be triggered with following minimal test case
(Adobe's Source Sans Pro font must be installed):
<style type="text/css">
p {
font-family: 'Source Sans Pro';
font-size: 24pt;
width: 275pt;
overflow-wrap: break-word;
}
</style>
<p>W1D1,W1D7,W2D14,W3D21,W4D28</p>
With the Adobe Source Sans Font the pango line wrapping algorithm
sometimes produces sporadic results. The wrapping seems to be dependent
on the following text, so that a short text doesn't "fit" on a line, but
does if it is followed by more text. This can be worked around in the
split_first_line() function by computing the resume offset at a later
point, so it is in sync with the actual wrapping behaviour.
See https://bugzilla.gnome.org/show_bug.cgi?id=777093.
As ::first-letter depends on white space handling, we must create the
box after collapsing spaces, not during the build of the box tree.
This commit makes WeasyPrint pass most of the W3C tests related to
first-letter (and never crash). Known problems left include:
- list markers are considered as the first letter,
- lines may break between the first letter and the rest of the text
(see #163 and #301),
- the CSS attributes are all kept, some should probably be removed (the
spec doesn't give a whole list).
Even if W3C tests makes me quite confident (some of them are crazy),
tests must be added in WeasyPrint too.
Python's tempfile.mkstemp already opens files, we don't have to open
them twice. The documentation is not really clear about that but
there's a good post on Logilab's blog: https://www.logilab.org/17873Fix#396.
The pseudo-element is currently added at the end of the build, but it
should be done during the layout as the whitespaces at the beginning of
the tags may be skipped.
As Pango keeps the extra trailing spaces when it splits lines, we try to
add the next word of the second line to the first line without its
trailing spaces and see if it fits. If it doesn't, we have to update
resume_at as we have split the first line at a position that may be
different from what Pango did earlier.
Fix#389.