1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 08:27:22 +03:00
Commit Graph

1313 Commits

Author SHA1 Message Date
Guillaume Ayoub
c818934b4c Fix import order 2017-07-25 14:00:24 +02:00
Guillaume Ayoub
fcd6bf7070 Clean and document the logging levels
Related to #488.
2017-07-25 13:59:56 +02:00
Guillaume Ayoub
f856edb3b4 Log the document generation steps
Related to #488.
2017-07-25 13:58:18 +02:00
Guillaume Ayoub
381678eec4 Don't draw all the lines when calculating the first line width
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.
2017-07-23 23:11:55 +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
344cb08f60 Don't copy styles when copying boxes, improve memory management
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.
2017-07-22 13:51:03 +02:00
Guillaume Ayoub
a9a99f69d7 Don't crash with @font-face{src: local()}
Fix #487.
2017-07-20 17:07:00 +02:00
Guillaume Ayoub
1fd38bdc7b Fix the local(Test Test) syntax in @font-face src
Related to #487.
2017-07-20 17:04:46 +02:00
Guillaume Ayoub
fb40d56b4a Remove the all_names attribute of matching_page_types 2017-07-18 12:02:30 +02:00
Guillaume Ayoub
cb45253bc9 Fix computed value of 'page' attribute 2017-07-18 12:01:50 +02:00
Guillaume Ayoub
9270697e80 Handle the page property 2017-07-18 02:01:36 +02:00
Guillaume Ayoub
f8088c3c92 Fix docstring 2017-07-18 00:22:33 +02:00
Guillaume Ayoub
30e4098b40 Set the page styles lazily 2017-07-17 23:40:59 +02:00
Guillaume Ayoub
c004dc47d1 Use a custom object instead of constants for page pseudo-classes
This is a first step to lazily get the page styles and support named pages.
2017-07-17 22:48:21 +02:00
Guillaume Ayoub
e0acecb4db Reorder imports 2017-07-13 17:39:29 +02:00
Guillaume Ayoub
718e4c3d8a Remove debug print 2017-07-13 17:38:12 +02:00
Guillaume Ayoub
140522c97c Merge pull request #485 from Kozea/cssselect2
Use cssselect2 instead of cssselect + lxml
2017-07-11 18:15:39 +02:00
Guillaume Ayoub
46da8b5107 Drastically improve speed when rendering preformatted text
Fix #483.
2017-07-07 14:26:38 +02:00
Guillaume Ayoub
dc225029a4 Fix wrong variable name 2017-07-07 14:05:12 +02:00
Guillaume Ayoub
dec5148e1b Fix import order 2017-07-07 11:52:40 +02:00
Guillaume Ayoub
a0dba07b67 Don't store base_url in ElementWrappers 2017-07-07 11:14:07 +02:00
Guillaume Ayoub
a11eeba00e Use ElementTree's element to get its tag 2017-07-03 15:31:17 +02:00
Guillaume Ayoub
ba26fa34a9 Use ElementTree's elements as much as possible 2017-07-03 15:19:05 +02:00
Guillaume Ayoub
9468957a23 Flatten stylesheets list 2017-07-01 07:41:13 +02:00
Guillaume Ayoub
42552e2069 Don't go through the tree twice when applying styles 2017-07-01 07:26:36 +02:00
Guillaume Ayoub
5a3a014ef2 Don't rely on network resources for tests 2017-07-01 07:19:12 +02:00
Guillaume Ayoub
df50204f3e Remove unsupported source lines 2017-07-01 00:28:14 +02:00
Guillaume Ayoub
07190e2fd9 Don't test 'tree' as a possible HTML source 2017-06-30 22:58:33 +02:00
Guillaume Ayoub
0f6647194b Get rid of lxml 2017-06-30 22:48:47 +02:00
Guillaume Ayoub
f349f8b276 Make HTML inherit from cssselect2.ElementWrapper 2017-06-30 20:12:53 +02:00
Guillaume Ayoub
4a5fa84f9f Use cssselect2 instead of cssselect 2017-06-30 17:54:02 +02:00
Guillaume Ayoub
baa698f473 Version 0.39 2017-06-24 14:17:13 +02:00
Guillaume Ayoub
c74b206abb Fix the use of WeasyPrint's URL fetcher with CairoSVG 2017-06-23 12:23:22 +02:00
Guillaume Ayoub
5b65283a22 Version 0.38 2017-06-16 11:35:42 +02:00
Guillaume Ayoub
ccf58d73af Fix a bug caused by the port to tinycss2
Fix #477.
2017-06-16 09:29:25 +02:00
Guillaume Ayoub
3151b5518a Version 0.37. 2017-06-15 08:21:40 +02:00
Guillaume Ayoub
86e4c63f4a Try to use WeasyPrint's URL fetcher in CairoSVG
Related to Kozea/Flask-WeasyPrint#11.
2017-06-07 11:37:53 +02:00
Guillaume Ayoub
b4a95c1fbe Why did isort decide to become this intolerant? 2017-06-03 16:05:33 +02:00
Guillaume Ayoub
10ee68d432 Fix imports for this crazy nazisort 2017-06-03 15:46:37 +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
1a66fa0fa4 Fix test with new freetype 2.8 version 2017-05-14 19:56:03 +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
Guillaume Ayoub
3677929a5b Add a documentation paragraph about the font_config attribute 2017-05-03 09:22:19 +02:00
Guillaume Ayoub
e44ae6d5e0 Merge branch 'master' of github.com:Kozea/WeasyPrint 2017-05-02 09:06:46 +02:00
Guillaume Ayoub
143fbd6efd Fix ::first-letter box creation
Fix #462
2017-05-02 09:05:04 +02:00
Hugh Secker-Walker
da3b5ae061 Add a minor peephole optimization 2017-05-01 17:54:52 -04:00
Hugh Secker-Walker
9c807b52d2 Start on support for asserting close numerical values 2017-05-01 17:54:17 -04:00
Hugh Secker-Walker
376bf0fd73 Fix mutable default-argument in MarginBox constructor 2017-05-01 17:54:03 -04:00
Guillaume Ayoub
b53d9d3b1f Cut long lines, remove an old note 2017-04-29 10:41:53 +02:00
Guillaume Ayoub
e89c3ddfb2 Merge branch 'typos-etc' of https://github.com/hughsw/WeasyPrint into hughsw-typos-etc 2017-04-29 10:26:23 +02:00
Guillaume Ayoub
273693d6f5 Add .isort.cfg
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.
2017-04-28 23:42:03 +02:00
Guillaume Ayoub
4875b932d9 Fix imports order 2017-04-28 22:55:34 +02:00
Hugh Secker-Walker
9376c95071 Fix typos and awkward grammar on Tutorial and API pages. 2017-04-28 14:36:14 -04:00
Guillaume Ayoub
517ba97af5 Merge branch 'master' of github.com:Kozea/WeasyPrint 2017-04-01 19:15:35 +02:00
Guillaume Ayoub
98ae8c7f95 Merge pull request #445 from Kozea/tinycss2
Switch to tinycss2
2017-04-01 19:04:08 +02:00
Tarashish Mishra
0fa6838c77 Let the logging module do the string interpolation 2017-03-28 13:02:50 +05:30
Guillaume Ayoub
c8b6794f14 Change an URL in comments 2017-03-26 21:43:23 +02:00
Simon Sapin
0aa62e249e Switch to tinycss2 2017-03-26 18:44:21 +02:00
Guillaume Ayoub
daf106e6d1 Don't justify children not in flow
Related to #39.
2017-03-26 17:53:57 +02:00
Guillaume Ayoub
ab2cdebb29 Don't shrink lines with floats by negative values
Related to #39.
2017-03-26 15:37:42 +02:00
Guillaume Ayoub
d3e4599ece Don't use werkzeug anymore in Navigator
Fix #133.

Actually, I'm not sure that Werkzeug was really useful.
2017-03-25 23:31:42 +01:00
Guillaume Ayoub
b3706b06cc Use percentage-resolved width and height to find replaced box height
Fix #327.
2017-03-25 23:02:38 +01:00
Guillaume Ayoub
1215cb586a Allow relative URIs in anchors
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.
2017-03-25 18:28:41 +01: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
ae040e1c71 Respect flake8 everywhere 2017-03-25 00:24:27 +01:00
Guillaume Ayoub
210b73820d Log to stderr only with CLI
Fix #412.
2017-03-24 23:12:04 +01:00
Guillaume Ayoub
e1d7d090e9 Version 0.36 2017-02-25 22:11:03 +01:00
Guillaume Ayoub
9c5a71d40d Merge branch 'master' of github.com:Kozea/WeasyPrint 2017-02-25 22:07:14 +01:00
Guillaume Ayoub
2fe75815d1 Version 0.35 2017-02-25 22:03:46 +01:00
Guillaume Ayoub
d6ab8ff542 Merge pull request #407 from Kozea/first
Handle ::first-letter
2017-02-16 15:46:41 +01:00
Andreas Pflug
25fdc0e949 Warn broken cairo version 2017-02-06 16:57:54 +01:00
Kyle Gibson
8983d96acd Fixed typos 2017-01-15 19:55:12 -05: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
1031371c7b Ignore boxes with no first-letter style 2017-01-02 13:44:03 +01:00
Guillaume Ayoub
5c9a07bf1a Create first-letter box after white space handling
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.
2017-01-02 13:23:42 +01:00
Guillaume Ayoub
e222779f0a Merge branch 'master' into first 2017-01-02 12:14:49 +01:00
Guillaume Ayoub
f53e8d05ed Version 0.34 2016-12-21 01:11:23 +01:00
Guillaume Ayoub
18b1931374 Clean and test columns
Fix #403.
2016-12-17 00:43:55 +01:00
Guillaume Ayoub
5a07ec0891 Fix the multi-page columns algorithm
Related to #403.
2016-12-16 17:37:39 +01:00
Guillaume Ayoub
cf0efe64cc Cast the number of columns into int
Should fix #403.
2016-12-15 09:02:14 +01:00
Guillaume Ayoub
bf6911d36f Correctly close files open by mkstemp
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/17873

Fix #396.
2016-12-07 18:25:58 +01:00
Guillaume Ayoub
12c297d7e7 Honor the presentational_hints option for PDFs
Related to #398.
2016-12-06 08:07:58 +01:00
Guillaume Ayoub
b9699688f6 Don't pass skip_stack to insert_first_letter 2016-12-04 16:55:29 +01:00
Guillaume Ayoub
4e8379cb90 Always use two colons for pseudo-elements
Tests now mix one and two colons in CSS, but the user agent stylesheet
and internal representation of the pseudo-elements now awlays use two
colons.
2016-12-04 16:43:49 +01:00
Guillaume Ayoub
5fa966bb42 Carefully check first-letter's char category
Use only the punctuation categories listed in the spec.
2016-12-04 16:33:03 +01:00
Guillaume Ayoub
c2cc15fd6a Initial support of ::first-letter
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.
2016-12-04 16:12:22 +01:00
Guillaume Ayoub
2614c48afc Version 0.33 2016-11-28 21:20:38 +01:00
Guillaume Ayoub
7ee1a746d8 Don't call add_top_padding when it's not needed 2016-11-25 01:21:26 +01:00
Guillaume Ayoub
92b3dbd00f Fix logic when finishing block formatting context
Related to #388.
2016-11-24 23:53:06 +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
292dc436d6 Merge pull request #393 from Kozea/osx-travis
Enable @font-face and add tests on MacOS
2016-11-21 20:16:43 +01:00
Guillaume Ayoub
521173b771 Try to render images as SVG first when sniffing 2016-11-21 09:29:55 +01:00
Guillaume Ayoub
68eb428919 Don't catch logs in mimetype sniffing test 2016-11-20 23:52:19 +01:00
Guillaume Ayoub
f89ef7b64a Fix data url in tests 2016-11-20 23:30:45 +01:00
Guillaume Ayoub
167e4513a8 Set a 1x1 size to sniffed SVG in tests 2016-11-20 22:59:48 +01:00