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
89b6fe39fc
Fix page break value comparison
2021-08-21 19:56:21 +02:00
Guillaume Ayoub
c191372e07
Test empty links and relative links with base
2021-08-06 20:04:57 +02:00
Guillaume Ayoub
35d20308e0
Test absolute tables and remove dead code
...
Table translation’s (dx, dy) can’t be (0, 0), because the table is in a table wrapper
that already takes care of (0, 0) values.
2021-08-06 19:32:49 +02:00
Guillaume Ayoub
f162d1b762
Fix and test line-clamp
2021-08-06 19:05:03 +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
694eddbc71
Embed images once
...
Images were already embedded once when included in the same stream.
Unfortunately, patterns have their own streams, meaning that a pattern used
multiple times includes the image each time. That’s especially bad for
different boxes using the same background, as backgrounds are drawn as
patterns.
Fix #1414 .
2021-08-03 18:39:02 +02:00
Guillaume Ayoub
f327a9e353
Don’t crash when leaders are in floats
...
Fix #1409 .
2021-08-01 19:06:13 +02:00
Guillaume Ayoub
cf267ee43a
Version 53.0
2021-07-31 22:30:16 +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
13a966b021
Check stream emptyness when drawing text
2021-07-30 15:51:55 +02:00
Lucie Anglade
d80e99dd6c
Fix use tags referencing svg and symbols, new episode
2021-07-30 15:49:10 +02:00
Lucie Anglade
e58ae27b99
Handle image mode I
2021-07-30 15:47:33 +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
08583d39bb
Handle font collections
...
Fix #1393 .
2021-07-29 20:50:50 +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
e30907c869
Simplify when begin/end text tags are inserted
...
The previous behaviour was introduced by 603ee26
as an optimization.
Unfortunately, it was not correct because text decoration can’t be drawn inside
the begin/end text tags. Generated PDF files were incorrect, leading to buggy
rendering by Ghostscript.
Related to #1400 .
2021-07-23 23:36:54 +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
56910a84e7
Take care of ratio when calculating min/max widths of replaced boxes
2021-07-19 19:49:20 +02:00
Guillaume Ayoub
071218ef12
Revert "Don’t crash with Pango 1.42"
...
This reverts commit 51b90ecf26
.
2021-07-18 23:17:01 +02:00
Guillaume Ayoub
51b90ecf26
Don’t crash with Pango 1.42
...
Debian stable (Buster, 10) includes Pango 1.42. Until the next version of
Debian (Bullseye, 11) is released, keep a workaround to avoid crashes.
This workaround is not documented on purpose, support of Pango 1.42 will not be
improved. Also note that WeasyPrint with Pango 1.42 will suffer from #1199 .
Fix #1384 .
2021-07-18 14:08:42 +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
aee609da43
Use stream variable name instead of old context
2021-07-17 14:29:28 +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
d8526d4b41
Fix and test resized SVG files
...
The SVG sample is 10 years old, and viewbox was lowercase. That’s viewBox, not
viewbox. Our new renderer is case-sensitive for attributes.
2021-07-17 00:53:39 +02:00
Guillaume Ayoub
e6be0fc47f
Fix text children
2021-07-16 15:17:15 +02:00
Guillaume Ayoub
5fe7ef6b22
Ignore missing glyphs when subsetting fonts
...
Instead of raising an error, just ignore missing fonts. Also include the notdef
glyph to (hopefully) avoid invalid documents.
Related to #1386 .
2021-07-13 20:16:20 +02:00
Guillaume Ayoub
8b8011ac78
Catch font subsetting errors
...
Fix #1386 .
2021-07-13 20:04:56 +02:00
Guillaume Ayoub
1111f7d57e
Handle stacking contexts put in contexts by previous generations
...
Fix #880 and fix #1396 .
2021-07-13 16:33:42 +02:00
Guillaume Ayoub
ea44564983
Typo in comment
2021-07-13 00:20:10 +02:00
Guillaume Ayoub
cbd617516f
Use cache index instead of Python id() for PDF image name
...
Cache index is reproducible between renderings, generating equivalent (and
testable) PDF files.
2021-07-12 22:50:05 +02:00
Guillaume Ayoub
04985cb5ab
Use image id instead of increasing index for image keys
...
Pillow images are stored in a cache, to be sure that we use the same image when
we have the same URL (and don’t try to retrieve it twice).
Using the image id as a key prevents WeasyPrint to store the image twice in the
PDF, with a large gain of time and size.
Related to #1392 .
2021-07-12 21:40:33 +02:00
Guillaume Ayoub
fa07d36fb0
Don’t force num_resolutions to 1 to make images smaller
...
Related to #1392 .
2021-07-12 21:39:55 +02:00
Guillaume Ayoub
5ae4afd35c
Use stream variable name instead of old-fashioned context
2021-07-12 16:57:48 +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
010f40adeb
Fix padding for columns
2021-07-11 17:40:02 +02:00
Colin Kinloch
f586992af5
Add text-align-last
2021-07-06 13:47:47 +01:00
Guillaume Ayoub
23dbd70c1f
Fix crash with borders whose widths are in em
...
Fix #1378 .
2021-06-13 08:07:46 +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
b24198df47
Version 53.0b2
2021-05-30 19:29:00 +02:00
Guillaume Ayoub
451258a3ec
Don’t include stroke width in g bounding boxes
2021-05-30 19:09:04 +02:00
Guillaume Ayoub
75e6d79c37
Linting
2021-05-30 18:56:41 +02:00
Guillaume Ayoub
ba41e7610a
Merge pull request #1358 from aschmitz/1352-multipage
...
Sort anchors across pages
2021-05-30 18:53:16 +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
aschmitz
ff94e03ac5
fix: remove debugging line
2021-05-19 11:53:09 -05:00
aschmitz
33348b4880
Sort anchors across pages
...
Previously we had sorted anchors within one page, but if anchors happened to be
out of order *across* pages, they wouldn't be written in order, which caused
lingering issues in some viewers.
Related to #1352 and the change in d4561b13af
.
2021-05-19 00:37:49 -05:00
Guillaume Ayoub
500545956a
Fix font type of embedded fonts
...
Fix #1357 .
2021-05-18 21:16:50 +02:00
Guillaume Ayoub
fd2901c570
Add docstrings to style classes
2021-05-12 18:28:15 +02:00
Guillaume Ayoub
d4561b13af
Sort anchors
...
Name trees, used to store PDF destinations (HTML anchors) have to be sorted
according to section 7.9.6 of the PDF 1.7 specification.
Fix #1352 .
2021-05-12 18:24:04 +02:00
Guillaume Ayoub
815c01f735
Add a warning when a font size can’t be optimized
2021-05-10 12:05:08 +02:00
Guillaume Ayoub
8acedd3e1b
Don’t duplicate embedded fonts when they have the same face
2021-05-09 20:42:53 +02:00
Guillaume Ayoub
9d7bf5ccd7
Remove useless variable
2021-05-09 19:56:13 +02:00
Guillaume Ayoub
f32cc56e25
Minor performance tweaks
2021-05-09 19:44:56 +02:00
Guillaume Ayoub
6d91c7ad29
Use __missing__ instead of __getitem__ for style
2021-05-08 09:03:45 +02:00
Guillaume Ayoub
2976292f5c
Make Style inherit from dict
2021-05-08 00:48:58 +02:00
Guillaume Ayoub
86796ed044
Use style class instead of computer dictionary
2021-05-07 22:39:57 +02:00
Guillaume Ayoub
b17b08dae7
Don’t crash with ex units in spacing properties
2021-05-07 16:38:51 +02:00
Guillaume Ayoub
bec7c37dc9
Minor cleanups for lazy style
2021-05-07 15:48:44 +02:00
Guillaume Ayoub
8504cfd65c
Calculate CSS properties on demand
...
Instead of calculating all the CSS properties for each element, we only get
them on demand. It saves A LOT of time and memory.
This implementation is just a quick and dirty hack that make tests pass. Even
with this suboptimal code, we get really good results.
Work in progress, has to be improved and cleaned.
2021-05-06 19:32:17 +02:00
Guillaume Ayoub
2d19becf19
Improve SVG support
2021-04-30 18:13:08 +02:00
Guillaume Ayoub
4f35e063d6
Add TODO for inline svg tags
2021-04-29 22:38:35 +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
Guillaume Ayoub
e126beb5fa
Comment and fix default stylesheets
2021-04-28 21:56:16 +02:00
Guillaume Ayoub
b476f2f606
Re-add deprecated CLI options
...
Related to #1232 .
2021-04-28 15:15:35 +02:00
Guillaume Ayoub
becd494f91
Add an option to optimize fonts
...
Fix #359 .
2021-04-28 14:55:52 +02:00
Guillaume Ayoub
71c49b58d1
Don’t crash when UA stylesheets can’t be read
...
That’s the case when flit builds packages and tries to get the package version.
2021-04-27 22:51:11 +02:00
Guillaume Ayoub
c76e1a3ba6
Use pkgutil instead of manual ROOT to load data
...
It avoids useless code and should work with all the packagers.
2021-04-27 22:11:27 +02:00
Guillaume Ayoub
6069fcd61a
Remove unused code
2021-04-26 18:03:59 +02:00
Guillaume Ayoub
51c673b343
Use almost the same code for gradients and patterns
2021-04-26 17:59:20 +02:00
Guillaume Ayoub
3ec32732aa
Fix gradients and tests
2021-04-26 17:36:18 +02:00
Guillaume Ayoub
f804d59cf3
Fix font flags
...
Related to #630 .
2021-04-26 15:06:35 +02:00
Guillaume Ayoub
3de9ff408d
Fix lint
2021-04-26 11:31:07 +02:00
Guillaume Ayoub
e983d88284
Version 53.0b1
2021-04-22 12:56:13 +02:00
Guillaume Ayoub
eae3540c55
Merge branch 'pydyfsvg'
2021-04-22 12:29:04 +02:00
Guillaume Ayoub
79bb88932c
Fix text rotation
2021-04-20 17:21:40 +02:00
Guillaume Ayoub
66f9720f9b
Allow strokes for text
2021-04-20 17:15:17 +02:00
Guillaume Ayoub
a4a5342bfb
Fix tspan
2021-04-20 17:05:05 +02:00
Guillaume Ayoub
b44bf650bd
Forget shapes that are not drawn
2021-04-20 16:53:21 +02:00
Guillaume Ayoub
82047b08e1
Fix text position
2021-04-20 16:44:31 +02:00
Guillaume Ayoub
dc861c785a
Add more tests for SVG images
2021-04-19 17:52:25 +02:00
Guillaume Ayoub
6bf74c7de2
Remove unneeded line breaks
2021-04-18 19:11:44 +02:00
Guillaume Ayoub
7e164db984
Use colorsys instead of home-made color conversion
2021-04-18 19:11:23 +02:00
Guillaume Ayoub
0c0367b2f2
Use "stream" instead of "context" when possible
...
We already have stacking contexts and layout contexts, there’s no need to use
"context" for "streams-with-context" too.
2021-04-18 18:50:11 +02:00
Guillaume Ayoub
4c56bb0851
Fix text position
2021-04-18 18:10:40 +02:00
Guillaume Ayoub
e00e027c9c
Fix SVG arcs
2021-04-18 18:01:56 +02:00
Guillaume Ayoub
3fc7273756
Test SVG bounding boxes
2021-04-18 17:20:07 +02:00
Guillaume Ayoub
541ed24472
Test SVG images
2021-04-18 16:01:26 +02:00
Guillaume Ayoub
0935813e75
Don’t handle text on a path
2021-04-17 18:30:18 +02:00
Guillaume Ayoub
6391139040
Add tests for text
2021-04-17 18:15:26 +02:00
Guillaume Ayoub
496ca5b14d
Update packaging information
2021-04-17 17:37:19 +02:00
Guillaume Ayoub
399413571e
Draw crop and cross marks
2021-04-17 14:41:03 +02:00
Guillaume Ayoub
d503bab165
Handle alpha in fill and stroke colors
2021-04-17 12:30:40 +02:00
Guillaume Ayoub
54fa4f95f5
Fix bug in matrix transformation
2021-04-17 12:29:48 +02:00
Guillaume Ayoub
604ed6e99e
Try to handle gradientTransform
2021-04-16 15:33:04 +02:00
Guillaume Ayoub
84f945d396
Fix userSpaceOnUse for gradients
2021-04-16 11:21:46 +02:00
Guillaume Ayoub
ed1869f14e
Avoid negative radius for radial gradients
2021-04-15 17:52:18 +02:00
Guillaume Ayoub
31cb0d76f3
Fix pattern drawing
2021-04-14 21:31:08 +02:00
Guillaume Ayoub
66d2b4da3c
First SVG text test
2021-04-14 16:56:30 +02:00
Guillaume Ayoub
744ad9dff4
Call begin_text and end_text when drawing text in SVG
2021-04-14 16:56:30 +02:00
Guillaume Ayoub
eb245c6e82
Replace directionality characters with zero-width space
...
As these characters were removed to avoid crashes when breaking lines, indices
returned were wrong and could cause crashes.
Replacing them with zero-width spaces adds a hack to the hack, but it keeps the
same indicies and should be harmless for rendering.
Of course, the real fix is to have real bidi support.
Fix #1336 .
2021-04-14 14:35:38 +02:00
Guillaume Ayoub
2502e0430b
Replace directionality characters with zero-width space
...
As these characters were removed to avoid crashes when breaking lines, indices
returned were wrong and could cause crashes.
Replacing them with zero-width spaces adds a hack to the hack, but it keeps the
same indicies and should be harmless for rendering.
Of course, the real fix is to have real bidi support.
Fix #1336 .
2021-04-14 14:34:21 +02:00
Guillaume Ayoub
36c076091a
Document and clean svg.utils
2021-04-12 17:19:46 +02:00
Guillaume Ayoub
087eae6ee0
Fix @import rules
2021-04-12 17:15:10 +02:00
Guillaume Ayoub
d29d22795a
Document and clean svg.text
2021-04-12 16:56:37 +02:00
Guillaume Ayoub
4fdde2188d
Comment and fix svg.shapes
2021-04-12 16:38:36 +02:00
Guillaume Ayoub
0756a0f424
Document and fix svg.path
2021-04-12 16:35:52 +02:00
Guillaume Ayoub
a425d1aa88
Document svg.image
2021-04-12 16:29:26 +02:00
Guillaume Ayoub
da2625f5a6
Document and comment svg.defs
2021-04-12 16:27:55 +02:00
Guillaume Ayoub
3aa34e2e0b
Document and comment svg.css
2021-04-12 15:49:06 +02:00
Guillaume Ayoub
ef9668ebf9
Use tinycss2.colors3 when possible
2021-04-12 15:21:43 +02:00
Guillaume Ayoub
75a422a70d
Clean and comment bounding box
2021-04-12 15:12:02 +02:00
Guillaume Ayoub
847ccc0a94
Comment draw_node
2021-04-12 14:32:57 +02:00
Guillaume Ayoub
bd2bc5cc7d
Fix text position
2021-04-12 14:30:30 +02:00
Guillaume Ayoub
a9144e582e
Clean and document svg.__init__
2021-04-12 14:25:55 +02:00
Guillaume Ayoub
c775ca6f46
Add bounding boxes for texts
2021-04-12 13:32:40 +02:00
Guillaume Ayoub
dd901bd8f6
Remove unused file
2021-04-11 16:15:36 +02:00
Guillaume Ayoub
0d8fb23145
Clean SVG support
2021-04-11 16:13:59 +02:00
Guillaume Ayoub
3a41d4e8a1
Initial support of text
2021-04-10 22:15:43 +02:00
Guillaume Ayoub
f52156ab0a
Fix x/y offsets with objectBoundingBox gradients
2021-04-05 15:45:20 +02:00
Guillaume Ayoub
8cbd0b0639
Handle masks, multiple fixes for gradients
2021-04-05 12:11:36 +02:00