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

2606 Commits

Author SHA1 Message Date
Guillaume Ayoub
9d300c1528 First SVG shapes 2021-03-07 18:00:38 +01:00
Lucie Anglade
a4ed61f1b6 Transform is done in pydyfsvg 2021-03-07 18:00:37 +01:00
Lucie Anglade
a5e20cfe4c Support SVG with pydyf 2021-03-07 18:00:37 +01:00
Guillaume Ayoub
9702348719 Remove last word before ellipses when hyphenated
Fix #1305.
2021-03-06 15:27:12 +01:00
Guillaume Ayoub
436378b349 Use the real layout text to draw characters 2021-03-06 12:44:19 +01:00
Guillaume Ayoub
8bd7f401c7 Fix last word detection
get_log_attrs indices are for Unicode characters, not for bytes.

Related to #1305.
2021-03-06 12:18:38 +01:00
Guillaume Ayoub
1cc2d632e6 Merge branch 'master' of github.com:Kozea/WeasyPrint 2021-03-02 16:00:13 +01:00
Guillaume Ayoub
5a9c2b4c58 Merge branch 'master' into doc 2021-03-02 15:51:26 +01:00
Guillaume Ayoub
da1219248a Prevent discarded boxes’ children from extending to the page bottom 2021-03-02 13:06:53 +01:00
Guillaume Ayoub
9eba07d0ac Merge branch 'master' into line-clamp 2021-02-23 12:38:08 +01:00
Guillaume Ayoub
694a926ec0 Fix height of "continue: discard" blocks 2021-02-23 12:12:48 +01:00
Guillaume Ayoub
50923ec71f Allow extra tokens for @import rules 2021-02-22 00:20:07 +01:00
Guillaume Ayoub
a156a2653a Fix imports with url() and quotes
Fix #1299. Related to Kozea/tinycss2#33.
2021-02-21 23:30:15 +01:00
Guillaume Ayoub
03183fb312 Add a lot of documentation 2021-02-18 21:03:40 +01:00
Guillaume Ayoub
02b71dd33a Fix text decoration
Fix #1297.
2021-02-18 13:57:17 +01:00
Guillaume Ayoub
224f7b3e8f Fix version 2021-02-18 11:39:44 +01:00
Guillaume Ayoub
c361b3c4e5 Remove VERSION 2021-02-18 11:33:20 +01:00
Guillaume Ayoub
6183a24545 Fix PangoGlyphUnit definition 2021-02-13 13:40:06 +01:00
Guillaume Ayoub
2c919858c8 Split the "text" module into submodules
The module was too long, and the font management was split into two different
modules. We now have everything in the "text" module.
2021-02-08 00:53:27 +01:00
Guillaume Ayoub
99267b13a6 Move text drawing to the "draw" module 2021-02-07 21:59:59 +01:00
Guillaume Ayoub
a90718ad50 Fix justification, letter-spacing and word-spacing 2021-02-06 17:31:32 +01:00
Guillaume Ayoub
66c09acb76 Use a .so.N file name to find libpangoft2
Related to #1003.
2021-02-05 11:32:16 +01:00
Guillaume Ayoub
5c4048946e Clean font optimization 2021-02-02 23:06:06 +01:00
Guillaume Ayoub
79f4983e04 Use real font flags 2021-02-02 22:39:19 +01:00
Guillaume Ayoub
1116c6485c Split fonts descriptions and font files
The goal of this commit is to have one PDF font for each Pango font (ie. for
each font description, including family, size, style, etc). When PDF fonts
share the same font file, we only include the font stream once and reference it
in each corresponding PDF font.

That’s probably the best way to have different metrics for each font
size. That’s also slow :/.
2021-02-02 21:48:20 +01:00
Guillaume Ayoub
05b9c71358 Use face content hash as key for fonts
It’s probably slow, but at least it’s reliable. We can find a better solution
later.

Related to #551.
2021-02-01 23:33:38 +01:00
Guillaume Ayoub
631de1ba8c Use Pango font description to get font hash
The hb_face value is different when the Pango font is different, and it causes
problems when multiple Pango contexts are used (for example when pages from
multiple documents are mixed).

Related to #551.
2021-02-01 22:38:27 +01:00
Guillaume Ayoub
efefb44b6e Handle RTL leaders 2021-01-24 20:55:06 +01:00
Guillaume Ayoub
4ce69dd06e Fix trailing spaces with RTL lines 2021-01-24 20:39:06 +01:00
Guillaume Ayoub
81f3abd9b8 Reorder inline children when direction is rtl 2021-01-24 18:28:12 +01:00
Guillaume Ayoub
cbc6322022 Split block-ellipsis and text-overflow implementations
The two properties work in very different ways, as described by the
specification. text-overflow only draws ellipsis at the end of the line, but
block-ellipsis requires a clean line break at word boundaries.
2021-01-22 19:40:59 +01:00
Guillaume Ayoub
75971401b0 Set text-overflow on last line when block-ellipsis is not "none" 2021-01-22 17:38:32 +01:00
Guillaume Ayoub
5920bf41fc Fix line-clamp and block-ellipsis validation 2021-01-22 17:27:15 +01:00
Guillaume Ayoub
301aa7912c Handle line-clamp 2021-01-22 17:04:37 +01:00
Guillaume Ayoub
bb2d1e14b5 Validate block-ellipsis 2021-01-22 16:54:44 +01:00
Guillaume Ayoub
d24c6246fa Fix box fragmentation when "continue" is set to "discard" 2021-01-22 16:48:26 +01:00
Guillaume Ayoub
68f12fe95d Clean comments for content-list token 2021-01-22 12:17:22 +01:00
Guillaume Ayoub
8967a387d4 Use f-strings when possible 2021-01-21 12:42:25 +01:00
Guillaume Ayoub
82007aeb17 Remove many getattrs 2021-01-20 22:14:44 +01:00
Guillaume Ayoub
56e17d9d6e Remove useless CLI options 2021-01-20 15:41:59 +01:00
Guillaume Ayoub
8193c72215 Avoid hasattr when possible 2021-01-20 15:18:01 +01:00
Guillaume Ayoub
74ce9ad8a3 Naive implementation of max-lines 2021-01-18 18:30:15 +01:00
Guillaume Ayoub
de17c7c3a0 Support the "continue" property 2021-01-18 17:40:32 +01:00
Guillaume Ayoub
c88225171f Allow line breaks before leaders, forbid them after 2021-01-18 16:29:42 +01:00
Guillaume Ayoub
c463fae778 Improve and clean line breaks for leaders 2021-01-18 15:49:33 +01:00
Guillaume Ayoub
62982e52ca Handle floats in lines where leaders are drawn
In some cases, leaders are translated after the layout, breaking the alignement
of characters in leader inline boxes. This bug has to be fixed (or not).
2021-01-11 14:38:20 +01:00
Guillaume Ayoub
a7511e3cff Clean the way boxes are created in "content" 2021-01-11 14:38:20 +01:00
Guillaume Ayoub
1043c5b94b Find leader index before adding text and moving boxes 2021-01-11 14:38:20 +01:00
Guillaume Ayoub
f40d81250c Clean and simplify leaders 2021-01-11 14:38:20 +01:00
Guillaume Ayoub
ff9888285c Initial support of leaders 2021-01-11 14:38:20 +01:00
Guillaume Ayoub
b2c7463701 Include witdh/height when calculating auto margins of absolute boxes
Fix #1264.
2021-01-11 13:14:55 +01:00
Guillaume Ayoub
093199d1ad Fix typo
Fix #1277.
2020-12-24 08:58:25 +01:00
Guillaume Ayoub
5cb1f67018 Merge branch 'master' of github.com:Kozea/WeasyPrint 2020-12-22 16:58:02 +01:00
Guillaume Ayoub
c35a629032 Don’t try to get an earlier page break between columns.
Fix #1191.
2020-12-22 16:51:27 +01:00
Guillaume Ayoub
9647b19516
Merge pull request #1268 from naveen521kk/new-names
Add new dll names
2020-12-22 15:45:42 +01:00
Guillaume Ayoub
a83824d6e1 Set font dictionary before use_references recursion 2020-12-21 14:38:18 +01:00
Guillaume Ayoub
c7b00e82e4 Add pattern type 2020-12-21 14:37:59 +01:00
Guillaume Ayoub
5f1710b74c Use references for smasks in images 2020-12-20 13:57:36 +01:00
Guillaume Ayoub
e166a672f5 Use a font dictionary shareda across the whole document 2020-12-20 12:37:17 +01:00
Guillaume Ayoub
5e932d3fca Revert "Use the same Resources dictionary across the whole document"
This reverts commit af92f3eba6.
2020-12-19 20:06:16 +01:00
Guillaume Ayoub
e4bcb07d55 Use the font descriptor as a reference 2020-12-19 19:02:24 +01:00
Guillaume Ayoub
af92f3eba6 Use the same Resources dictionary across the whole document 2020-12-19 19:01:29 +01:00
Guillaume Ayoub
626177bd20 Include padding, border, padding when calculating inline-block width
Fix #1235.
2020-12-14 07:12:41 +01:00
Syrus Dark
8635f538d7
fix line length 2020-12-14 09:30:35 +05:30
Syrus Dark
44d78f208c
Add new dll names
When building Pango with meson I get the following dll files as output.
So adding it.
2020-12-14 09:13:25 +05:30
Guillaume Ayoub
a8e900110d Don’t render layouts with no size 2020-12-13 15:07:35 +01:00
Guillaume Ayoub
b2f7afd29d Revert "Don’t compress streams"
This reverts commit d0ca0da6bb.
2020-12-12 22:44:41 +01:00
Guillaume Ayoub
d0ca0da6bb Don’t compress streams 2020-12-12 22:34:43 +01:00
Guillaume Ayoub
30c21d92e9 Fully remove Cairo from documentation and code 2020-12-10 22:47:27 +01:00
Guillaume Ayoub
f10b3b56c8 Fix error raised when SVG images are rendered 2020-12-08 15:51:35 +01:00
Guillaume Ayoub
7fe4e74b2e Don’t round glyph positions to PDF points
Fix #1199.
2020-12-08 00:03:50 +01:00
Guillaume Ayoub
cfb9017e84 Remove CairoSVG
Fix #1263.
2020-12-07 12:27:18 +01:00
Guillaume Ayoub
4f82a4a34e Packaging!
Related to #1247, #1232.
2020-12-06 20:19:59 +01:00
Guillaume Ayoub
d6cbf25880 Merge branch '52.x' 2020-12-06 19:40:51 +01:00
Guillaume Ayoub
bf45c2eb9f Merge 52.2 2020-12-06 19:35:24 +01:00
Guillaume Ayoub
5ec1881c51 Version 52.2 2020-12-06 19:14:14 +01:00
Guillaume Ayoub
5c91212624 Really print a lot of things when tests fail 2020-12-06 14:09:22 +01:00
Guillaume Ayoub
b4e0619158 Print a lot of things when tests fail 2020-12-06 13:49:58 +01:00
Guillaume Ayoub
a677b3d3ae Print command result when test fails 2020-12-06 13:27:33 +01:00
Guillaume Ayoub
a2e02086d7 Assert at least one magic number in Ghostscript output 2020-12-06 13:12:13 +01:00
Guillaume Ayoub
a849f9e88b Try to clean tests 2020-12-06 12:47:20 +01:00
Guillaume Ayoub
b65c3649cb Fix Ghostscript’s stdout for Windows 2020-12-02 01:33:22 +01:00
Guillaume Ayoub
e5542c9539 Use better names for harfbuzz library discovery 2020-12-02 01:05:56 +01:00
Guillaume Ayoub
578a191f52 Don’t use capture_output, unsupported by Python 3.6 2020-12-01 12:49:19 +01:00
Guillaume Ayoub
5ed5b54d59 Handle transparent colors in gradients correctly
Gradients must be drawn using a pre-multiplied color space. It means that stop
colors are "weighted" by their alpha channel when we define how transition is
done between two colors.

To explain why this is needed, the best example is "transparent". The
"trasparent" color is set to rgba(0, 0, 0, 0), also known as transparent
black. When there’s a transition from red to transparent, we don’t want to have
a transition to black, as it would be if RGBA values were extrapolated. We want
to have a transition to transparent red.

This problem appears for each transition between colors whose RGB and A
channels are both different.

To fix this, we use the same plain color as the one from the previous stop for
transitions to transparent, and the same plain color as the one from the next
stop for transitions from transparent. For semi-transparent colors, we set a
weight proportional to the color alpha, meaning that opaque colors will take
more place than transparent ones.

This bug appears in Safari: https://bugs.webkit.org/show_bug.cgi?id=150940.
It obviously means that we’re better than Apple. Obviously.
2020-11-30 20:54:26 +01:00
Guillaume Ayoub
29a90fcf2b Merge branch 'pydyf' of github.com:Kozea/WeasyPrint into pydyf 2020-11-30 19:12:59 +01:00
Guillaume Ayoub
5f5f30d3e8 Support transparent gradients 2020-11-30 19:12:41 +01:00
Lucie Anglade
c72539f7ca Remove print 2020-11-29 20:14:37 +01:00
Guillaume Ayoub
f6456f9c0c Remove useless @requires from one test 2020-11-28 14:14:43 +01:00
Guillaume Ayoub
6b1a7970cb Correctly draw borders on the last line of split tables
The previous logic used to find if a row is in the footer was broken. Code is
now cleaner, shorter, with an example in comments and a non-regression test.

Fix #1250.
2020-11-25 14:19:32 +01:00
Guillaume Ayoub
f0231c8b15 Correctly draw borders on the last line of split tables
The previous logic used to find if a row is in the footer was broken. Code is
now cleaner, shorter, with an example in comments and a non-regression test.

Fix #1250.
2020-11-23 20:46:09 +01:00
Guillaume Ayoub
236d1dd309 Don’t render table cells as if they are on empty pages
The page_is_empty was probably set to True to force rendering, but using
max_position=inf should already allow all cells to be rendered.

When cells are rendered with page_is_empty set to True, the top margin of their
first children is removed, because margins are always removed at the top of
blocks split between multiple pages.

Fix #1254.
2020-11-21 19:24:48 +01:00
Guillaume Ayoub
6606927007 Fix URL handling with tinycss2
URLs used to be dedicated tokens in the CSS specification, but it’s now a
common function unless its value isn’t quoted.

tinycss2 1.1.0 includes this change, and WeasyPrint has to take care of these
two different tokens.
2020-11-21 19:24:43 +01:00
Guillaume Ayoub
2af9a49c09 Fix error messages in tests 2020-11-21 19:24:41 +01:00
Lucie Anglade
a6f9c80921 A nice gif to please gdk-pixbuf 2.42.0
See https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/162
2020-11-21 19:15:48 +01:00
Guillaume Ayoub
70229deef7 Don’t render table cells as if they are on empty pages
The page_is_empty was probably set to True to force rendering, but using
max_position=inf should already allow all cells to be rendered.

When cells are rendered with page_is_empty set to True, the top margin of their
first children is removed, because margins are always removed at the top of
blocks split between multiple pages.

Fix #1254.
2020-11-21 18:24:18 +01:00
Guillaume Ayoub
af37f05a95 Version 52.1 2020-11-02 21:40:16 +01:00
Guillaume Ayoub
238e214f9d Fix URL handling with tinycss2
URLs used to be dedicated tokens in the CSS specification, but it’s now a
common function unless its value isn’t quoted.

tinycss2 1.1.0 includes this change, and WeasyPrint has to take care of these
two different tokens.
2020-10-30 11:05:27 +01:00
Guillaume Ayoub
77dbcb79b8 Fix error messages in tests 2020-10-30 10:39:26 +01:00
Guillaume Ayoub
a3c3bb56af Version 52 2020-10-30 00:40:14 +01:00
Guillaume Ayoub
18010a152e Disable WOFF and WOFF2 font formats support
WOFF and WOFF2 formats are supported by FreeType, but for some reason Cairo
doesn’t include the fonts correctly.

WOFF(2) fonts already work on the branch where Cairo is not used anymore.

Fix #1237.
2020-10-27 21:12:56 +01:00
Guillaume Ayoub
0b3105037a Merge branch 'master' into pydyf 2020-10-27 18:36:32 +01:00
Guillaume Ayoub
1e3a0d28c4 Move an import at the top of the module
It was in a function, even if it wasn’t a circular import. As this function was
called a lot of times, it was actually really slow.
2020-10-27 18:23:50 +01:00
Guillaume Ayoub
d45ecd3465 Merge branch 'master' into pydyf 2020-10-26 23:46:27 +01:00
Guillaume Ayoub
92dca05ff7 Don’t create a layout to know if a line break is possible
We now have a faster function to do this, let’s use it!
2020-10-26 23:42:33 +01:00
Guillaume Ayoub
a0031a899c Fix can_break_text
The number of log attrs is the number of characters, not the number of
bytes. Using the number of bytes just returns garbage.
2020-10-26 23:41:24 +01:00
Guillaume Ayoub
5497991fb4 Don’t retry to split a line if it contains spaces
Splitting the line twice takes too much time, and we know (hope?) that we can
always split lines after a space.
2020-10-26 22:11:29 +01:00
Guillaume Ayoub
431c11e7a0 Put write_png in testing suite for license considerations 2020-10-26 17:26:01 +01:00
Guillaume Ayoub
94cf4bf5e0 Fix colors in repeating linear gradients 2020-10-25 20:18:13 +01:00
Guillaume Ayoub
a7c1f3dcbc Fix gradient tests 2020-10-25 20:18:05 +01:00
Guillaume Ayoub
8cd28aee31 Small fixes on linear gradients 2020-10-25 15:52:58 +01:00
Guillaume Ayoub
1ff768c103 Support linear gradients 2020-10-25 14:54:08 +01:00
Guillaume Ayoub
60df2d174e Handle repeating radial gradients 2020-10-25 13:41:23 +01:00
Guillaume Ayoub
02e6beb041 Fix gradient documentation and comments 2020-10-25 07:32:41 +01:00
Guillaume Ayoub
b434b563bf Remove unused imports 2020-10-24 21:43:05 +02:00
Guillaume Ayoub
b37feca543 Fix radial gradients and related tests 2020-10-24 21:35:17 +02:00
Guillaume Ayoub
7f2c64e5a6 Handle degenerate radial gradients 2020-10-24 20:49:42 +02:00
Guillaume Ayoub
18e567c95e Fix radial gradients 2020-10-24 20:46:38 +02:00
Guillaume Ayoub
2ed1f6f59d Allow some pixels to be ignored in tests 2020-10-24 20:46:16 +02:00
Guillaume Ayoub
04f40ae9b2 Fix various tests 2020-10-24 18:00:48 +02:00
Guillaume Ayoub
06b3c954c4 Fix CSS validation tests 2020-10-24 17:48:24 +02:00
Guillaume Ayoub
bd0a6eee45 Fix non-repeating linear gradients 2020-10-24 17:42:13 +02:00
Guillaume Ayoub
01fe5504e4 Fix links 2020-10-23 13:08:29 +02:00
Guillaume Ayoub
12999bded8 Merge branch 'master' into pydyf 2020-10-23 12:36:03 +02:00
Guillaume Ayoub
bf89df5b67 Use axis variable instead of relying on flex-direction property 2020-10-21 21:03:34 +02:00
Guillaume Ayoub
638b70e3e3 Deduplicate flex logic for rtl
Related to #1225.
2020-10-21 21:03:01 +02:00
Mohammed Y. Alnajdi
a81a82dc4c Kozea/WeasyPrint#601: fix indentation 2020-10-11 08:49:57 +03:00
Mohammed Y. Alnajdi
0c2e7b2341 Kozea/WeasyPrint#601: remove TODO:handle RTL 2020-10-10 23:14:21 +03:00
Mohammed Y. Alnajdi
2a01aefeb5 Kozea/WeasyPrint#601: add flex rtl tests row & col 2020-10-10 22:04:49 +03:00
Mohammed Y. Alnajdi
ecb97b1854 Kozea/WeasyPrint#601: handle flex-direction column 2020-10-10 21:45:45 +03:00
Mohammed Y. Alnajdi
1e35ab3c5e flexbox: initial attempt to support flex with rtl 2020-10-03 20:42:36 +03:00
Mohammed Y. Alnajdi
251157944e added rtl flexbox test 2020-10-03 20:41:59 +03:00
Guillaume Ayoub
b545239f1e
Merge pull request #1146 from Tontyna/bookmark-label
Bookmark label
2020-09-23 21:33:18 +02:00
Guillaume Ayoub
c9385a4b0f Use the old square character for list
Fix #1182.
2020-09-23 20:50:21 +02:00
Lucie Anglade
fa92372cdb When adding embedded files, the Catalog dictionary is extended with a Name entry only when there isn’t one.
When there is already a Name entry in the Catalog, it’s the Name which is extended as the Catalog can have only one Names entry according to the PDF’s spec.

Internal links were broken with embedded files because an other Name entry was added and so PDF readers forgot the previous one containing the link’s destination.

Fix #1203.
2020-09-21 15:28:53 +02:00
Lucie Anglade
30bf467ce8 Cairo use hex string when there are parenthesis for TAG_LINK but not for TAG_DEST so an id is not represented by the same string in the pdf and pdf reader can make the link between them. Using urllib.parse.quote replaces special chars and so Cairo stop using hex string and pdf reader are happy. 2020-09-13 18:42:56 +02:00
Lucie Anglade
a9822fbb83 Remove useless import 2020-09-10 12:07:10 +02:00
Lucie Anglade
325c9cb7b4 Fix test 2020-09-10 12:04:13 +02:00
Lucie Anglade
c5a06dbeae Clean code 2020-09-10 11:58:19 +02:00
Lucie Anglade
8612c374bd Add download test for attachment 2020-09-10 11:44:49 +02:00
Lucie Anglade
1519424378 Fix ci’s isort 2020-09-10 00:57:08 +02:00
Lucie Anglade
5de2bda477 Add missing space 2020-09-10 00:53:02 +02:00
Lucie Anglade
b1bb6b78bb isort 2020-09-10 00:52:41 +02:00
Lucie Anglade
a9a24f754f Use download attribute in <a> to define filename for attachment 2020-09-10 00:51:03 +02:00
Guillaume Ayoub
254f8fa935 Remove backslash 2020-09-04 08:40:18 +02:00
Guillaume Ayoub
89ab158868
Merge pull request #1165 from mikevoets/fix/variables-concatenation-in-content
Add support for concatenating var() functions in 'content' declarations
2020-09-04 08:12:40 +02:00
Guillaume Ayoub
c607c01a8c Fix a crash with a flexbox corner case
When the flex box height percentage can’t be solved using its parent heihgt,
its computed height is set to 'auto' even if the specified value is not
'auto'. It’s a problem when the flex box has multiple lines, because in this
case we rely on the computed height to distribute the extra space between the
lines.

Fix #1204.
2020-09-01 21:20:04 +02:00
Guillaume Ayoub
c9b27bdbb4 Simplify image mode management 2020-08-03 18:18:55 +02:00
Guillaume Ayoub
4539a91101 Handle images with transparency color 2020-08-02 15:44:39 +02:00
Guillaume Ayoub
b1baa9ea51 Handle trasparent images 2020-08-02 15:07:32 +02:00