1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-09-11 20:47:56 +03:00
Commit Graph

215 Commits

Author SHA1 Message Date
Guillaume Ayoub
2b94b922f9 Handle inheritance for defined elements 2022-11-13 12:25:00 +01:00
Mikhail Anikin
0de8df6621 Fix rem font size for SVG images
SVG pictures can have font size in rem
2022-10-27 15:14:14 +03:00
Guillaume Ayoub
8c8d059052 Don’t crash when currentColor is set on root svg tag
Fix #1740.
2022-10-15 16:19:37 +02:00
Guillaume Ayoub
c9c9b3da9d Minor changes
Improvements provided by refurb.
2022-10-05 18:22:35 +02:00
Guillaume Ayoub
c7265f5bc2 Improve coverage and fix gradient painting 2022-09-27 10:59:31 +02:00
Guillaume Ayoub
7d2913ccad Improve coverage 2022-09-26 17:25:29 +02:00
Guillaume Ayoub
11bc920910 Merge branch '56.x' 2022-07-10 20:38:07 +02:00
Guillaume Ayoub
f2cecc78ea Fix gradients with opacity set
Fix #1678.
2022-07-10 20:37:33 +02:00
Guillaume Ayoub
5d9e5f7040 Update and fix URLs in comments and documentation 2022-06-28 15:59:06 +02:00
Guillaume Ayoub
e38bff8b99 Don’t crash when inherited SVG attributes are not set on the parent 2022-06-17 10:07:28 +02:00
Guillaume Ayoub
358b9469bf
Merge pull request #1651 from Kozea/pdfa
Support PDF/A
2022-06-13 14:52:12 +02:00
Guillaume Ayoub
26d5d8264d Don’t check origin when URL only contains fragment
Fix #1650.
2022-05-27 17:32:16 +02:00
Guillaume Ayoub
61ee64ecac Fix domain for gradients 2022-05-27 11:26:24 +02:00
Guillaume Ayoub
09364c254e Refactor PDF generation 2022-05-27 11:26:15 +02:00
Guillaume Ayoub
6ade02b234 Use f-strings when possible 2022-05-17 16:40:30 +02:00
Guillaume Ayoub
1545a45092 Merge branch '55.x' 2022-05-10 14:34:25 +02:00
Guillaume Ayoub
50ad4d1ac0 Fix relative paths for SVG files stored as data URLs
Fix #1641.
2022-05-10 14:31:25 +02:00
Guillaume Ayoub
99294a76b5 Use different attribute name for text bounding box 2022-04-28 18:57:01 +02:00
Guillaume Ayoub
506e1908ea Merge branch '55.x' 2022-04-28 18:50:57 +02:00
Guillaume Ayoub
f621392e2b Fix SVG opacity bounding box coordinates 2022-04-28 18:50:30 +02:00
Guillaume Ayoub
0fcc7de817 Don’t stop rendering SVG when CSS parsing fails
Fix #1625.
2022-04-28 17:36:06 +02:00
Guillaume Ayoub
fb3c39e0fc Don’t stop rendering SVG when CSS parsing fails
Fix #1625.
2022-04-28 17:35:25 +02:00
Guillaume Ayoub
ec93efc2e7 Unwrap lines 2022-04-28 16:48:46 +02:00
Guillaume Ayoub
d42cb9176a Fix text bounding box in SVG 2022-04-28 16:48:46 +02:00
Guillaume Ayoub
607f26fbd7 Fix viewboxes in SVG markers 2022-03-27 21:46:28 +02:00
Guillaume Ayoub
7fd7413aa2 Test (and fix) SVG markers 2022-03-27 19:57:02 +02:00
Guillaume Ayoub
0792c0d3a3 Clean docstrings in modules 2022-03-25 11:47:27 +01:00
Guillaume Ayoub
abb3184b9e Put the Matrix class in a separate module
It avoids imports in functions and makes document.py a bit smaller.
2022-03-19 17:47:28 +01:00
Guillaume Ayoub
d814c2e879 Remove useless dots used for old float divisions 2022-02-14 11:02:09 +01:00
Guillaume Ayoub
cf0622128a Use the default value of decode/encode when possible 2022-02-14 10:55:47 +01:00
Guillaume Ayoub
e17e5368f7 Update and clean docstrings. 2022-02-14 07:11:30 +01:00
Guillaume Ayoub
9ffc124ab8 Merge branch '54.x' 2022-02-06 20:48:12 +01:00
Guillaume Ayoub
d60433a1da Don’t duplicate the definition of SVG attributes
We want to get this list set only once, because we don’t want to change it
twice each time we add or remove an attribute.

This change probably means that extra work is now done, for style and for
definitions. This should definitely be optimized, but at least it shouldn’t be
wrong.

Tests definitely have to be added for SVG rendering.

Fix #1558.
2022-02-06 20:35:39 +01:00
Rian McGuire
9a845cfdbb Avoid invalid PDF operators when drawing SVG text
According to the PDF specification, "special graphics state" operators (q, Q, cm) aren't permitted while a text object is being drawn.
2022-01-27 17:14:20 +11:00
Guillaume Ayoub
21314bc726 Use math.inf instead of float('inf') 2022-01-24 11:35:43 +01:00
Guillaume Ayoub
302f09d54a Always use absolute paths to get hrefs in SVG
Also be more fault-tolerant when trying to render use tags.

Fix #1531.
2022-01-03 14:14:36 +01:00
Guillaume Ayoub
ed20d94c49 Don’t restore current point after empty paths
See Kozea/CairoSVG#346.
2021-11-06 09:23:54 +01:00
Guillaume Ayoub
dce0e56aeb Merge branch '53.x' 2021-11-04 09:36:38 +01:00
Guillaume Ayoub
f3936ca856 Use better approximations for font ascent and descent values in SVG
It’s hard to get real values, because it would require to access the font
information. But we can at least use values related to the font size, so that
alignment doesn’t get totally wrong.

Related to #1485.
2021-11-04 09:35:13 +01:00
Guillaume Ayoub
fd4711edbe Handle quotes in url(…) syntax
Related to #1485
2021-11-04 09:35:08 +01:00
Guillaume Ayoub
35ab45fbba Merge branch '53.x' 2021-10-03 10:19:46 +02:00
Guillaume Ayoub
ab3ff79bd7 Fix patterns 2021-10-03 10:19:31 +02:00
Guillaume Ayoub
ab631cd596 Merge branch '53.x' 2021-10-02 17:39:15 +02:00
Guillaume Ayoub
f87e1cbe1b Use SVG width/height as inner size when no viewBox is given
Fix #1455.
2021-10-02 17:38:43 +02:00
Guillaume Ayoub
a809eff415
Merge pull request #1434 from Kozea/emojis
Draw PNG and SVG emojis
2021-09-13 15:13:11 +02:00
Guillaume Ayoub
9a720ac081 Don’t serialize and parse again inline SVG files
Fix #1443.
2021-09-12 17:40:19 +02:00
Guillaume Ayoub
37af386852 Cache SVG use tags
Fix #1439.
2021-09-11 14:57:47 +02:00
Rian McGuire
7c4fd020fe Fix marker-start being drawn on mid vertices 2021-09-01 10:08:13 +02:00
Rian McGuire
e4734e05ca Fix marker-start being drawn on mid vertices 2021-09-01 12:38:09 +10:00
Guillaume Ayoub
cb97228c04 Initial support of SVG emojis
Related to #1406.
2021-08-30 11:10:24 +02:00
Guillaume Ayoub
8ef8c39a03 Initial support of PNG emojis
Related to #1406.
2021-08-29 19:34:28 +02:00
Guillaume Ayoub
64d04c47b6 Merge branch '53.x' 2021-08-27 22:01:02 +02:00
Guillaume Ayoub
228520d8e6 Handle cx and cy in SVG rotations
Fix #1430.
2021-08-27 21:59:34 +02:00
Guillaume Ayoub
61ff7f0e1c Handle full "display" property
In CSS Display Module Level 3, the "display" property gets a long
representation allowing:

- a clear separation between inner and outer display type,
- new supported types (contents, run-in, flow-root…),
- inline list items.

This commit allows the (retrocompatible) new long syntax for "display". It also
supports the "flow-root" value. It doesn’t support values related to ruby, and
it doesn’t support the new "contents" and "run-in" display types.

This work gives the possibility to simplify the code in the block_*_layout
functions, and to improve the overall layout.

Related to #36.
2021-08-23 21:54:28 +02:00
Guillaume Ayoub
3aca9f1f84 Change the resume_at and skip_stack structure
Many operations, including page breaks, require a pointer to a specific
position of the box tree. For example, we used to have this structure to point
to the beginning of the first child of the second child:

(1, (2, None))

We now use:

{1: {2: None}}

This change is the first step to handle parallel flows (see #36). It doesn’t
change anything to the layout for now, but it allows us to store multiple
pointers in the same structure.

The next step is to handle multiple pointers in skip_stack during boxes layout.
It means that most of the *_layout() function need an extra for-loop to manage
multiple skip stacks.

We’ll then need to split new types of boxes: table cells, floats, absolutes…
2021-08-22 12:10:48 +02:00
Guillaume Ayoub
2e96bdee35 Simplify API to get intrinsic size of images
The previous API wasn’t stateless, as it sometimes required to call
get_intrinsic_size before accessing intrinsic_ratio. The new API offers a
single method to get width, height and ratio.
2021-08-03 18:39:14 +02:00
Guillaume Ayoub
783378d14a Fix reference for percentages 2021-07-31 08:29:23 +02:00
Guillaume Ayoub
3e11acafb2 Include origin translation into matrix for patterns 2021-07-31 01:06:50 +02:00
Guillaume Ayoub
fd973a195a Fix origin translation for SVG gradients 2021-07-31 00:57:47 +02:00
Guillaume Ayoub
f240bae0b8 Handle SVG image tags for images with no intrinsic size 2021-07-31 00:30:00 +02:00
Lucie Anglade
8c23e982e8 Preserve ration when drawing image in svg 2021-07-30 17:15:15 +02:00
Lucie Anglade
cd42c6cabf Clip embedded svg 2021-07-30 16:42:00 +02:00
Lucie Anglade
11a175efc7 Handle x and y in use tags 2021-07-30 16:32:25 +02:00
Lucie Anglade
7f6e99bc58 Handle errors in points 2021-07-30 16:08:19 +02:00
Lucie Anglade
d80e99dd6c Fix use tags referencing svg and symbols, new episode 2021-07-30 15:49:10 +02:00
Lucie Anglade
6de791a3a1 Fix use tags referencing svg and symbols 2021-07-30 15:42:51 +02:00
Lucie Anglade
603736407c Do not crash when bounding box is unknown 2021-07-30 15:23:04 +02:00
Lucie Anglade
c104c8e099 Handle unit in dash array 2021-07-30 15:15:50 +02:00
Lucie Anglade
9bcece11fe Fix blend mode 2021-07-30 15:12:06 +02:00
Guillaume Ayoub
5a53e11608 Clean and fix some cases of SVG gradients 2021-07-25 18:30:32 +02:00
Guillaume Ayoub
6417023f3d Fix translation when viewBox’s origin is not 0,0
Related to #1400.
2021-07-23 23:59:14 +02:00
Guillaume Ayoub
a5b9db5160
Merge pull request #1401 from pbregener/issue-1399
More robust handling of SVG use tags
2021-07-23 22:38:26 +02:00
Guillaume Ayoub
a0ad94b143 Don’t stroke when stroke-width is 0
Related to #1403.
2021-07-23 22:36:05 +02:00
Guillaume Ayoub
8d7bcead0a Fix how x and y attributes are handled
Fix #1403.
2021-07-23 22:17:37 +02:00
pbregener
96daadf742
More robust handling of SVG use tags
Fixes #1399
2021-07-20 18:10:04 +02:00
Guillaume Ayoub
5fba476370 Test and fix text-anchor 2021-07-18 10:09:03 +02:00
Guillaume Ayoub
23b99475c2 Use "in" when possible 2021-07-18 10:08:50 +02:00
Guillaume Ayoub
c7b97fa3bf Handle simple cases of clip-path
Fix #1374.
2021-07-18 09:36:14 +02:00
Guillaume Ayoub
add1dad80b Use named parameters for stream transformation 2021-07-17 14:25:58 +02:00
Guillaume Ayoub
a4cc61c7b8 Use matrix.values instead of indices 2021-07-17 13:46:46 +02:00
Guillaume Ayoub
e6be0fc47f Fix text children 2021-07-16 15:17:15 +02:00
Guillaume Ayoub
cef8cf109d Fix and simplify image size management 2021-07-12 15:07:31 +02:00
Guillaume Ayoub
231736d73e Use the original SVG tree when drawing patterns
In Pattern, we want self.tree to be the pattern tree when we call draw(), but
we want self.tree to be the original SVG tree for everything else, like finding
defs.

This commit replaces self.tree with the original SVG tree after we call draw().

Fix #1394.
2021-07-12 11:42:07 +02:00
Guillaume Ayoub
08f3a59d4f Strip quotes from font names in SVG
Fix #1393.
2021-07-12 10:54:11 +02:00
Guillaume Ayoub
c0c9879bc5 Handle stroke-opacity and fill-opacity
This commit also cleans a lot of things about the way opacity is handled,
with many small bug fixes.

Fix #1371.
2021-06-02 20:35:06 +02:00
Guillaume Ayoub
41d4a262d3 Don’t copy the already-cascaded style when copying nodes
Fix #1370.
2021-06-01 22:30:54 +02:00
Guillaume Ayoub
edf47f5311 Copy nodes when drawing them as use tags
Fix #1370.
2021-06-01 22:11:11 +02:00
Guillaume Ayoub
6dde6cb5e9 Fix SVG transform order
Fix #1369.
2021-05-31 22:37:18 +02:00
Guillaume Ayoub
451258a3ec Don’t include stroke width in g bounding boxes 2021-05-30 19:09:04 +02:00
Guillaume Ayoub
0f8deb86a7 Include stroke width in bounding box
Fix #1367.
2021-05-30 09:50:40 +02:00
Guillaume Ayoub
f17acdcd02 Rename SVG.paint 2021-05-30 09:50:30 +02:00
Guillaume Ayoub
bb8eea9066 Fix style attributes in SVG
Fix #1366.
2021-05-27 16:36:34 +02:00
Guillaume Ayoub
41ab0f86e7 Cascade inherited attributes for use tags
Fix #1365.
2021-05-27 12:04:41 +02:00
Guillaume Ayoub
a3028945fc Handle visibility and display attributes
Fix #1362.
2021-05-25 15:01:07 +02:00
Guillaume Ayoub
2d19becf19 Improve SVG support 2021-04-30 18:13:08 +02:00
Guillaume Ayoub
3818df4b96 Use a "more elegant way" to handle stroke-dasharray="none"
Related to #1346.
2021-04-29 17:54:04 +02:00
Guillaume Ayoub
264246959b
Merge pull request #1346 from pbregener/svg-stroke-dasharray-none
SVG: Allow stroke-dasharray:none
2021-04-29 17:45:26 +02:00
Guillaume Ayoub
9f38063379 Use page coordinates when no bounding box is found for opacity 2021-04-29 16:52:00 +02:00
pbregener
06ef510ddf
SVG: Allow stroke-dasharray:none
Fixes a crash when a SVG contains
`style="stroke-dasharray:none"`
2021-04-29 11:42:46 +02:00
Guillaume Ayoub
26cc19ce16 Fix double x/y transform for use tags
Fix #1345.
2021-04-28 21:57:15 +02:00