1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 16:37:47 +03:00
Commit Graph

166 Commits

Author SHA1 Message Date
Guillaume Ayoub
56904baa79 Use the same copyright line everywhere 2018-09-20 18:46:27 +02:00
Guillaume Ayoub
ab62ae1d3c Clean some comments and some code 2018-04-30 22:57:47 +02:00
Guillaume Ayoub
58f1f40904
Merge pull request #599 from Tontyna/test-api
Fix some pytest failures on Windows
2018-04-30 22:19:46 +02:00
Guillaume Ayoub
d37060399b Lint 2018-04-13 11:00:13 +02:00
Guillaume Ayoub
f6bd84e4ab Warn users with cairo < 1.15.4
Related to #339, #565, #616.
2018-04-13 10:44:19 +02:00
Tontyna
2c2092d27b Prevent Cairo crashing with font-size 0 2018-03-31 18:10:51 +02:00
Guillaume Ayoub
c167d7cad0 Don't use global variable for dictionaries 2018-03-25 16:26:39 +02:00
Guillaume Ayoub
4bdfae4eb6 Don't use a global cache to store font features 2018-03-25 16:20:24 +02:00
Guillaume Ayoub
db401ac0cb Don't create dummy cairo contexts each time a Layout is created
Saves a loooooot of time when a lot of text is drawn.

Related to #578.
2018-03-18 22:37:56 +01:00
Guillaume Ayoub
3b52fb058e Don't optimize resume_at when splitting lines with trailing spaces
Fix #586.

For some reason I don't really understand, stripping trailing spaces that would
make the line too long can't be optimized when the space is at the end of the
block. Returning None instead of the index of the last letter should be
possible, but it breaks the rendering when the first letter of the next line
box starts with a character that doesn't allow line breaks after spaces (many
punctuation characters for example) and that doesn't allow line wrap.

This change shouldn't be harmful, as the removed code lines were just cleaning
the resume_at value without changing the logic of line breaking. I suppose that
there's a bug somewhere else.
2018-03-10 00:26:11 +01:00
Guillaume Ayoub
63db508efb Ignore overflow_wrap: break-word when calculating min-content width
See https://drafts.csswg.org/css-text-3/#overflow-wrap-property

Fix #582.
2018-03-05 01:23:32 +01:00
Guillaume Ayoub
ee6b506002 Remove useless empty line 2018-01-29 23:30:57 +01:00
Guillaume Ayoub
7e03734ba4 Remove useless comment 2018-01-29 22:22:54 +01:00
Guillaume Ayoub
16e8186568 Drop Python 2 support 2018-01-14 01:48:17 +01:00
Guillaume Ayoub
ad11edfff2 Remove StyleDict objects 2018-01-13 17:41:08 +01:00
Guillaume Ayoub
724565f27a Don't allow attribute access to StyleDict objects 2018-01-13 17:05:23 +01:00
Guillaume Ayoub
31520990ac Don't compare Nones and ints 2018-01-09 23:42:56 +01:00
Guillaume Ayoub
995a9a324d Always set resume_at to None when reaching end of text
Fix #557.
2018-01-09 18:12:32 +01:00
Guillaume Ayoub
7be183f234 Remove broken optimization 2017-12-11 01:38:57 +01:00
Guillaume Ayoub
a7b192c1d3 Small fixes for line breaking 2017-12-11 00:20:49 +01:00
Guillaume Ayoub
71917af2fb Linebox breaks fixes and related tests 2017-12-10 01:01:55 +01:00
Guillaume Ayoub
0412f54bb4 Use Pango instead of uniseg to break lines 2017-10-24 08:47:22 +02:00
Guillaume Ayoub
60fadc81bc Fix comments 2017-10-21 19:23:45 +02:00
Guillaume Ayoub
588203b9eb Remove useless line_width parameter and line_widths function 2017-10-21 16:56:25 +02:00
Guillaume Ayoub
f7903925fd Use a separate variable for justification spacing 2017-08-01 10:07:36 +02:00
Guillaume Ayoub
a3e2c474f0 Transform StyleDict into a kind of frozen dict
This forces to use a copy when changes are needed. Internal mutable structures
have also been changed into immutable ones (i.e. lists have been turned into
tuples).

This change is a really useful first step to greatly optimize memory and time
needed to render large documents, as allows us to cache style dicts more
safely. It's been already done in StyleDict.inherit_from, with a ~5-10% memory
benefice.
2017-07-28 13:35:06 +02:00
Guillaume Ayoub
fcd6bf7070 Clean and document the logging levels
Related to #488.
2017-07-25 13:59:56 +02:00
Guillaume Ayoub
279e50790d Don't crash when max_width is infinite 2017-07-23 23:10:36 +02:00
Guillaume Ayoub
91b58db81f Cut long lines before splitting them
This optimization had been added and removed before, but it's really useful for
very long lines.
2017-07-23 22:05:48 +02:00
Guillaume Ayoub
dc225029a4 Fix wrong variable name 2017-07-07 14:05:12 +02:00
Guillaume Ayoub
81094997ee Don't crash when lines start with multiple soft hyphens
Related to #472.
2017-06-03 15:40:13 +02:00
Guillaume Ayoub
975586c24f Set an infinite layout width when the lines have already been split
Fix #449.
2017-06-03 15:14:27 +02:00
Guillaume Ayoub
78f0d7f8a2 Move the shrink-to-fit hack from text.py to inline.py
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.
2017-05-14 15:07:28 +02:00
Simon Sapin
0aa62e249e Switch to tinycss2 2017-03-26 18:44:21 +02:00
Guillaume Ayoub
c1accaa58e Use warnings instead of logs to advertise about old libraries 2017-03-25 15:57:06 +01:00
Guillaume Ayoub
4f4b4ed598 Use isort in tests 2017-03-25 00:33:36 +01:00
Guillaume Ayoub
b2282dd6f8 Try to use WRAP_CHAR instead of WRAP_WORD_CHAR
And add some comments to explain why it doesn't work. Related to #410.
2017-01-11 13:45:24 +01:00
Martin Natano
4919f3a643 Fix AssertionError in layout.inlines.split_text_box().
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.
2017-01-11 12:14:03 +01:00
Guillaume Ayoub
eb08c46489 Use second line's index instead of first line length 2016-11-22 02:37:04 +01:00
Guillaume Ayoub
8cb093c021 Always update resume_at when splitting lines
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.
2016-11-22 01:11:02 +01:00
Guillaume Ayoub
f401eb7f62 Don't unref attribute lists for text features
Tried many times at many places of the code, it always segfaults. Keep
them for now.
2016-11-05 19:02:54 +01:00
Guillaume Ayoub
72022e421d Merge remote-tracking branch 'origin/master' into perf 2016-11-03 12:55:14 +01:00
Guillaume Ayoub
cff44522fc Don't recreate new text layouts when not needed 2016-11-02 01:48:58 +01:00
Guillaume Ayoub
b680963c91 Don't store dummy context in Layout
This has an amazing results on memory: -15% when rendering the first page
of the HTML5 spec.
2016-11-02 01:02:10 +01:00
Guillaume Ayoub
ade095ad88 Break long line 2016-10-30 21:17:15 +01:00
Simon Sapin
fd69b3656d Cache Pango font-features attributes to avoid leaking too many of them. 2016-10-30 14:04:11 +01:00
Guillaume Ayoub
95c76ad4a9 Don't free pango attribute lists
Using the garbage collector to free them makes WeasyPrint segfault,
let's keep them in memory forever for now.
2016-10-28 18:35:26 +02:00
Guillaume Ayoub
308aaab526 Merge branch 'master' into font-face 2016-10-27 17:43:49 +02:00
Guillaume Ayoub
152193cf77 Add the font configuration in LayoutContext
The font configuration is available (almost) everywhere it's needed,
@font-face doesn't rely on a global state anymore.
2016-10-27 17:36:24 +02:00
Guillaume Ayoub
f215a67ba4 Fix the "requires" decorator 2016-10-26 19:11:21 +02:00