1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-03 23:48:07 +03:00
Commit Graph

616 Commits

Author SHA1 Message Date
Guillaume Ayoub
71e9e257cc Always set font size when font is changed in line
In setting the font size also sets the font family, and that’s useful when we
have different fonts in the same text block. It happens for example when
characters are missing from a font and are replaced by a fallback font’s
character.

Fix #1748.
2022-10-21 22:29:00 +02: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
ab914a52d3 Fix and test corner cases about white spaces and running elements 2022-10-09 20:11:20 +02:00
Guillaume Ayoub
4185ad3409 Don’t remove attachments when adding internal anchors
Fix #1733.
2022-10-04 11:16:33 +02:00
Guillaume Ayoub
ad5222b65f Remove useless import 2022-10-03 17:10:01 +02:00
Guillaume Ayoub
709184b7d9 Remove print 2022-10-01 11:34:05 +02:00
Guillaume Ayoub
4f7c3cfa1d Unmark tests for gradients 2022-09-30 18:47:36 +02:00
Guillaume Ayoub
028ec78ccc Clean Ghostscript error 2022-09-27 11:23:09 +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
cecad07166 Improve test coverage 2022-09-24 06:31:03 +02:00
Guillaume Ayoub
a4fc7a11a9 Handle image-orientation 2022-09-23 15:44:16 +02:00
Guillaume Ayoub
58c5f29925 Allow the skew() function to take only one parameter
Fix #1722.
2022-09-22 10:26:23 +02:00
Guillaume Ayoub
6fb4c08e49 Fix top-margin of out-of-flow elements at the top of pages
We were already trying to get the correct top margin of the child, but we
didn’t include subtleties introduced by unforced page breaks. The logic is
still duplicated, it already was, but at least now the copy-paste is correctly
done.

Fix #1058.
2022-09-21 18:17:46 +02:00
Guillaume Ayoub
c274f9fb54
Merge pull request #1704 from Kozea/pdf-ua
Support PDF/UA
2022-09-17 00:05:34 +02:00
Guillaume Ayoub
450cbd430f Add tests for footnotes in columns 2022-09-15 13:55:05 +02:00
Guillaume Ayoub
cf67b267ea Display sizes when drawing tests fail 2022-09-13 12:11:06 +02:00
Guillaume Ayoub
b99dc71cb5 Rename test file for footnotes 2022-09-13 12:04:10 +02:00
Guillaume Ayoub
738a1679be Fix corner-case test
As explained in the comment, the rendering here is not defined. At least now we
display all the footnotes…
2022-09-13 09:12:05 +02:00
Guillaume Ayoub
9e1bf174ff Cut too long lines 2022-09-06 10:02:25 +02:00
Guillaume Ayoub
9ab4623a58 Go through the variable resolution for special inheritance cases
Fix #1697.
2022-08-29 23:16:23 +02:00
Guillaume Ayoub
3fca521d67 Merge branch 'master' into pdf-ua 2022-08-18 15:58:57 +02:00
Guillaume Ayoub
67cd41a9dd
Merge pull request #1695 from lutrasecurity/lang
Add language information to PDF
2022-08-18 15:58:29 +02:00
Guillaume Ayoub
9a4c5fc3c9 Fix the way column rules are drawn 2022-08-18 15:22:45 +02:00
Guillaume Ayoub
e9c45c7060 Clean and test "text-transform: capitalize"
Related to #1703.
2022-08-15 16:08:06 +02:00
Guillaume Ayoub
c64eec81cc Correctly detect reported footnotes for repagination
Fix #1700.
2022-08-15 12:26:06 +02:00
Konstantin Weddige
42db8bdb03 Update tests 2022-07-22 12:22:22 +02:00
Guillaume Ayoub
86a6597e61 Don’t store or test download names anymore
They’re actually not used at all.
2022-07-21 11:44:54 +02:00
Guillaume Ayoub
5c91673b9d Add failing test for broken nested counters
Related to #1685.
2022-07-18 11:07:15 +02:00
Guillaume Ayoub
0a21cf9ffe Merge branch '56.x' 2022-07-13 22:48:06 +02:00
Guillaume Ayoub
adec43adc4 Fix code and tests for max-height set on footnotes
The bug in the code was caused by the page_is_empty variable. It’s useless to
test this variable here because we know that we rendered at least the current
line. It’s not updated earlier, but if it were it would always be True.

This commit also fixes minor bugs in the tests.

Fix #1674.
2022-07-13 22:45:26 +02:00
Lucie Anglade
8f5bee1d51 Some tests for max-height on footnote area.
Related to #1674.
2022-07-13 22:10:12 +02:00
Guillaume Ayoub
91a2474400 Fix OTB test on Fedora
The metrics and floats roundings seems to be slightly different on different
platforms. Using a lower line-height value should fix the problem everywhere.

Fix #1677.
2022-07-13 10:23:57 +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
99b6d301da Merge branch '56.x' 2022-07-07 17:26:13 +02:00
Guillaume Ayoub
9ce65478b2 Fix default vertical position of out-of-flow split elements
Fix #1673.
2022-07-07 17:18:12 +02:00
Guillaume Ayoub
76d174f578 Fix split table headers’ top border when rows are split 2022-07-07 15:43:51 +02:00
Guillaume Ayoub
cb9540ba3b Correctly detect empty split lines at the end of tables
The previous detection was failing when some cells were empty (or fully
rendered) and when the current rendering position was not overflowing the page.
In this case, the line with empty cells was rendered and was visible for
example when cells had padding.
2022-07-07 10:45:24 +02:00
Guillaume Ayoub
c028c672d7 Merge branch '56.x' 2022-07-05 16:14:17 +02:00
Guillaume Ayoub
3bd9a8e014 Don’t limit the opacity groups to the original box size
It doesn’t work when elements are displayed outside or when the box is
transformed.
2022-07-05 16:06:46 +02:00
Guillaume Ayoub
2484ca2cc7 Rotate images with EXIF rotation
Fix #1667.
2022-07-02 15:01:16 +02:00
Guillaume Ayoub
bcf40367d7 Merge branch '56.x' 2022-07-01 09:43:09 +02:00
Guillaume Ayoub
1a4d2a70ef Fix and test nth selector for pages
Fix #1668.
2022-07-01 09:42:24 +02:00
Guillaume Ayoub
5feaf5e084 Fix and add failing test
We still have a lot of corner cases to fix for floats, judging from the number
of xfail tests in this file…
2022-06-30 16:12:02 +02:00
Guillaume Ayoub
902bde7d9c Take care of floats when removing placeholders
Removing placeholders is something we have to do when we must discard a part of
the layout that has already been done. It currently removes absolutely
positioned placeholders and footnotes.

The same has to be done with split floats, that’s what this commit is about.

We have to change the structure of the broken_out_of_flow attribute, as we have
to get a reliable way to reach the saved data using from the real element in
the tree. The new structure is thus a dictionary whose keys are the boxes in
the tree (placeholder for absolutes, partial elements for floats) and whose
values are the original_box+parent+resume_at.

Fix #1669.
2022-06-30 15:29:50 +02:00
Guillaume Ayoub
74f367c2a3 Merge branch '56.x' 2022-06-29 19:06:58 +02:00
Guillaume Ayoub
00d5b03587 Don’t break reproducible PDF creation when using images
Fix #1666.

Note that the added test doesn’t test this problem, because the "hash" function
is stable when we use the same process. If someone finds a nice way to solve
this…
2022-06-29 19:03:58 +02:00
Guillaume Ayoub
5d9e5f7040 Update and fix URLs in comments and documentation 2022-06-28 15:59:06 +02:00
Guillaume Ayoub
c031a40439
Merge pull request #1660 from Kozea/line-clamp
Support nested line-clamp
2022-06-17 10:09:38 +02:00
Guillaume Ayoub
d8533dad9c
Merge pull request #1644 from Kozea/bitmap-fonts
Bitmap fonts
2022-06-17 10:08:49 +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
eadd5c0c7b Remove xfail for passing tests about opacity 2022-06-16 17:23:09 +02:00
Guillaume Ayoub
d3883c4428 Test nested line-clamp 2022-06-13 16:36:05 +02:00
Guillaume Ayoub
191e015f89 Test bitmap fonts 2022-06-13 16:23:44 +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
04e1ff2f7a Fix chained variables in the same selector block
As a side effect, fix also the case when a variable is missing in the root
element.

Fix #1656.
2022-06-10 20:10:33 +02:00
Guillaume Ayoub
e4885f9cff Don’t crash when @font-face’s src ends with a comma
That was the only @comma_separated_list function to assume "tokens" is not
empty.

Fix #1653.
2022-06-01 16:59:30 +02:00
Guillaume Ayoub
3211163f8c Add and fix tests for custom metadata 2022-05-27 11:26:24 +02:00
Guillaume Ayoub
bff1dd5b22 Add option to set PDF version
Related to #1131.
2022-05-27 11:26:24 +02:00
Guillaume Ayoub
ed84e5a8ea Test PDF/A 2022-05-27 11:26:24 +02:00
Guillaume Ayoub
09364c254e Refactor PDF generation 2022-05-27 11:26:15 +02:00
Guillaume Ayoub
e212c83b50 Remove useless parameters from testing utils 2022-05-23 23:09:32 +02:00
Guillaume Ayoub
a001af7c33 Remove useless parameters from tests helpers 2022-05-23 12:01:11 +02:00
Guillaume Ayoub
56b79ba375 Fix test name 2022-05-23 09:55:13 +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
96f26504ce Use the original box when breaking waiting children
Before this commit, when we had to break previously rendered waiting children
in a line, we re-rendered the already-rendered children. That was bad, because
the tree of the children that were already rendered were different from the
original tree, that may include leading spaces for example. It also required a
complex mix of the original resume-at with the original skip-stack.

This new solution includes both the original child (to render it from a fresh
start) and the already-rendered child (to get the previous positions). The
skip-stack mix is now useless, removing a lot of complex code.

This change is scary and will probably break some corner cases. But tests pass,
and a new one has been added to avoid future regressions.

Fix #1638.
2022-05-09 22:39:31 +02:00
Guillaume Ayoub
c53528753b Merge branch '55.x' 2022-05-05 16:29:26 +02:00
Guillaume Ayoub
bc4053510a Fix absolute position for rtl
Fix #1637. Related to #1613.
2022-05-05 16:28:55 +02:00
Guillaume Ayoub
a4d52533ec Add and improve tests for the "html" module 2022-05-05 15:47:43 +02:00
Guillaume Ayoub
733815c96b Test invalid images 2022-05-04 16:01:40 +02:00
Guillaume Ayoub
491503c482 Handle "footnote-policy: auto" footnotes correctly 2022-05-03 09:48:17 +02:00
Guillaume Ayoub
eb489e5847 Minor cleanups 2022-05-03 09:33:14 +02:00
Guillaume Ayoub
7fe5e43a2d Minor cleanups 2022-05-02 22:34:51 +02:00
aschmitz
2f207d13ab fix: sequential footnotes could disappear when overflowing
Previously, if a footnote triggered an overflow (that is, it was too
large for the containing space), but footnote-policy didn't make us push
down the line containing it, any subsequent footnotes in the same
linebox would not be set into a footnote area, because they would never
be passed to layout_footnote and report_footnote. (Their call sites
would be set, but their content would not be.)

This also fixes a potential infinite loop where using footnote-policy
could have forced the first line of a page to be pushed to the next
page: that will just result in an infinite loop, so instead we set the
line and move on if we are on the first line of a page. (This behavior
is not specified in GCPM, but no other behavior seems practical: the
only alternative would be to expand the page, which is almost certainly
less desirable.)
2022-05-02 21:50:31 +02:00
aschmitz
29bd8f932f fix: sequential footnotes could disappear when overflowing
Previously, if a footnote triggered an overflow (that is, it was too
large for the containing space), but footnote-policy didn't make us push
down the line containing it, any subsequent footnotes in the same
linebox would not be set into a footnote area, because they would never
be passed to layout_footnote and report_footnote. (Their call sites
would be set, but their content would not be.)

This also fixes a potential infinite loop where using footnote-policy
could have forced the first line of a page to be pushed to the next
page: that will just result in an infinite loop, so instead we set the
line and move on if we are on the first line of a page. (This behavior
is not specified in GCPM, but no other behavior seems practical: the
only alternative would be to expand the page, which is almost certainly
less desirable.)
2022-05-02 14:27:51 -05:00
Guillaume Ayoub
aa348dabe7 Add failing test about floats
Related to #1629.
2022-04-28 16:48:46 +02:00
Guillaume Ayoub
bc1770f97b Rename tests 2022-04-28 16:48:46 +02:00
Lucie Anglade
185ea5380f Make test pass indenpently of default font size 2022-04-28 12:12:09 +02:00
Guillaume Ayoub
67075b4c46 Merge branch '55.x' 2022-04-25 23:43:37 +02:00
Guillaume Ayoub
3ad6982f4e Fix available height for absolute boxes with "bottom" property set
Fix #1626.
2022-04-25 23:42:36 +02:00
Guillaume Ayoub
3802f8857a Fix the y position of split absolute boxes 2022-04-25 23:42:24 +02:00
Guillaume Ayoub
2a8ca143c0 Revert and test "Remove useless condition"
This reverts commit 34944e06c4.
2022-04-25 19:07:33 +02:00
Guillaume Ayoub
e5e6b88203 Reset the bottom space even when we don’t fill the columns 2022-04-25 19:07:23 +02:00
Guillaume Ayoub
964109867f Stop rendering when column content doesn’t fit in the page 2022-04-25 19:07:13 +02:00
Guillaume Ayoub
f5b970eb26 Revert and test "Remove useless condition"
This reverts commit 34944e06c4.
2022-04-25 19:05:53 +02:00
Guillaume Ayoub
e1de59af96 Reset the bottom space even when we don’t fill the columns 2022-04-25 18:30:27 +02:00
Guillaume Ayoub
6bd5a59a04 Stop rendering when column content doesn’t fit in the page 2022-04-25 18:26:04 +02:00
Guillaume Ayoub
1e4fde4ee0 Clean font management 2022-04-19 00:01:50 +02:00
Guillaume Ayoub
709255bc44 Test overconstrained relative blocks 2022-04-18 14:43:22 +02:00
Guillaume Ayoub
1b8ba2c3ab Test string(…, start) 2022-04-18 13:08:32 +02:00
Guillaume Ayoub
ee19c6af9c Test break-before: page on root boxes 2022-04-18 12:51:21 +02:00
Guillaume Ayoub
c2b2457f54 Test reset page counters 2022-04-18 12:06:36 +02:00
Guillaume Ayoub
a869831740 Add drawing tests 2022-04-18 11:48:35 +02:00
Guillaume Ayoub
aa4df152e9 Remove more and more white backgrounds 2022-04-17 09:32:15 +02:00
Guillaume Ayoub
d4f3fcfd71 Clean, fix and test backgrounds 2022-04-17 09:22:13 +02:00
Guillaume Ayoub
ae8f3b4cc8 Clean expanders tests and code 2022-04-17 07:34:03 +02:00
Guillaume Ayoub
1cb02f03b5 Add tests for CSS prefixes 2022-04-16 15:49:14 +02:00
Guillaume Ayoub
f3763b8bfa Remove useless white backgrounds from tests 2022-04-16 13:54:07 +02:00
Guillaume Ayoub
20f8924dda Test border radius 2022-04-16 13:47:14 +02:00
Guillaume Ayoub
3ccbc8f077 Add more tests for leaders 2022-04-16 12:27:57 +02:00
Guillaume Ayoub
e544398b00 Mark tests as failing because of Ghostscript
See https://bugs.ghostscript.com/show_bug.cgi?id=705225.
2022-04-15 15:47:05 +02:00
Guillaume Ayoub
2e726a3965 Don’t generate PDF with 0-scale transformation matrices for text 2022-04-15 14:53:19 +02:00
Guillaume Ayoub
d49f93fcd2 Test skew for links 2022-04-15 12:19:42 +02:00
Guillaume Ayoub
e06e829b5d Try hard to follow break-inside: avoid-column 2022-04-13 23:03:50 +02:00
Guillaume Ayoub
79f7677a43 Fix test
Even if there are many unsupported cases, this one was a real bug in the test.

Related to #1621.
2022-04-13 10:21:19 +02:00
Guillaume Ayoub
af9a495177 Improve inheritance of text-decoration-* properties
The text-decoration-* properties are not inherited anymore, they are propagated
according to specific rules.

This commit removes the inheritance, but it doesn’t follow all the rules
defined by the specification. The new behavior is not perfect, but it should be
at least better than the previous code and opens the possibility to fix this
issue correctly in the future.

Failing tests have been added.

Fix #1621.
2022-04-13 09:39:09 +02:00
Guillaume Ayoub
20c91dcef5 Fix multiple text decorations drawing
Fix #1621.
2022-04-12 14:59:13 +02:00
Guillaume Ayoub
6ba031e8c7 Fix skip stacks for columns
Fix #984, fix #1604.
2022-04-09 08:51:51 +02:00
Guillaume Ayoub
eb997d1573 Draw borders around absolute images
Fix #1093.
2022-04-05 12:37:20 +02:00
Guillaume Ayoub
56f0d4adb0 Deactivate orphans and widows for tests
The default "2" value for orphans and widows is really useful for real
documents, but it can be very disturbing for tests and introduce false
negatives and false positives.
2022-04-03 16:42:11 +02:00
Guillaume Ayoub
04b0f45e50
Merge pull request #1619 from Kozea/break-column
Initial support of column breaks
2022-04-03 15:54:18 +02:00
Guillaume Ayoub
48f784e718 Add and improve tests for breaks in columns 2022-04-03 13:41:23 +02:00
Guillaume Ayoub
9e1b1560af Add missing asserts in tests 2022-04-02 18:54:23 +02:00
Guillaume Ayoub
3f3956844a Test SVG transforms 2022-03-27 22:26:53 +02:00
Guillaume Ayoub
ea50bc578a Add one SVG marker test 2022-03-27 21:46:43 +02:00
Guillaume Ayoub
7fd7413aa2 Test (and fix) SVG markers 2022-03-27 19:57:02 +02:00
Guillaume Ayoub
fe1f3d9e98 Fix and test broken absolutes in lines 2022-03-25 21:37:44 +01:00
Guillaume Ayoub
089ffa4480 Add tests for absolutes 2022-03-25 15:27:58 +01:00
Guillaume Ayoub
f39c5ab4b0 Add an improve tests for SVG 2022-03-25 15:20:22 +01:00
Guillaume Ayoub
0792c0d3a3 Clean docstrings in modules 2022-03-25 11:47:27 +01:00
Guillaume Ayoub
2f8d4999d7
Merge pull request #1613 from Kozea/fix_1512
ltr for absolute boxes
2022-03-24 18:10:59 +01:00
Lucie Anglade
b33cb3f26d Add some tests 2022-03-23 18:26:47 +01:00
aschmitz
ad6e0d729f perf: improve column handling speed, fix infinite loops
The primary change here is that the column calculation algorithm now
attempts to render columns as if they were the full remaining height on
the page, rather than to render the entire content regardless of how
long the page is.

The worst-case behavior is effectively the same as that of the previous
algorithm (as at least one additional pass would be required to
determine how high balanced columns should be, but this applies in both
cases), but if content would not fit on the page, this can bail and set
the page immediately, rather than continuing significantly more
calculations.

As an associated benefit, this closes #1020, as we now handle multiple
column breaks (which would force a page break) correctly. A test for
this behavior is included.
2022-03-17 00:32:02 -05:00
Guillaume Ayoub
ea558e8b63
Merge pull request #1588 from aschmitz/absolutes-in-footnotes
fix: support position: absolute in footnotes
2022-03-07 16:02:27 +01:00
aschmitz
e7397c8b50 fix: support position: absolute in footnotes
Previously, this would throw an error because absolute_layout hadn't had
a chance to lay out the boxes. Now we do the block level layout for
footnotes *before* doing layout for absolute boxes (or fixed boxes) and
add any positioned boxes to positioned_boxes so they can be put onto the
page correctly.
2022-03-03 22:10:21 -06:00
Guillaume Ayoub
7034d67e07 Merge branch '54.x' 2022-03-02 21:07:31 +01:00
Guillaume Ayoub
c1178a559c Fix (and test) discarded text-align values
Fix #1586.
2022-03-02 20:57:26 +01:00
Guillaume Ayoub
a969ec1c64
Merge pull request #1570 from aschmitz/fix-repeat-unlayout
fix: more robustly handle unlayout'ing a footnote
2022-02-26 09:00:19 +01:00
aschmitz
9b0a672acd fix: handle float rounding when extending boxes over page breaks
When a box would break over the edge of a page, its height is extended
to the bottom of that page (per
https://www.w3.org/TR/css-break-3/#box-splitting , primarily to allow
backgrounds and borders to continue to the end of the page).

When this happened, sometimes the values that would be calculated for
the height of the extended element would be rounded *over* the
calculated height that remained on the page, forcing the entire
containing box to wrap to the next page.

Rather than trying to carefully manage the order of operations to try to
be safe in IEEE floats for directions, we apply a small "fudge factor":
if an element fits very nearly (within a thousandth of a pixel) into the
remaining space, it is still accepted.
2022-02-20 14:42:48 +01:00
aschmitz
1d7ddfdf38 fix: more robustly handle unlayout'ing a footnote
This fixes a bug accidentally introduced in #1566, where we would try to
unlayout a footnote that had not yet been laid out, if the algorithm
decided that there would be insufficient space on a page before laying
out a further footnote.
2022-02-14 17:51:28 -06:00
Guillaume Ayoub
cf0622128a Use the default value of decode/encode when possible 2022-02-14 10:55:47 +01:00
Guillaume Ayoub
0a6f86945b Don’t remove soft hyphens before drawing text 2022-02-14 08:55:09 +01:00
Guillaume Ayoub
c9871cf7fb Remove useless dels 2022-02-14 08:15:55 +01:00
aschmitz
f953fb8de0 fix: don't output footnotes before their call sites
If a footnote has been output but we then decide to cancel the line it
was output on, we should cancel the output of the footnote itself.

This requires a bit of extra bookkeeping, so we know which footnotes are
relevant, but otherwise largely works using the existing
remove_placeholders code.

Includes a minor refactor of footnote area management in LayoutContext,
and a new testing utility: `tree_position`.

Closes #1564.
2022-02-10 01:02:21 -06:00
Guillaume Ayoub
9003fd0490 Use utf-8 instead of utf8 2022-02-08 22:41:03 +01:00
Guillaume Ayoub
c3c5f08e91 Merge branch '54.x' 2022-02-08 12:19:41 +01:00
Guillaume Ayoub
562a2499a1 Fix line break when breaks occur between a nbsp and an inline block
This commit:

- fixes the trailing space detection, by handling all trailing spacing
  characters that could be ignored by Pango’s line break algorithm;
- tries harder to break waiting children when a line break occurs in an
  inline block that can’t be separated from the previous one.

Fix #1562.
2022-02-08 12:16:10 +01:00
aschmitz
7f8545c560 fix: handle float rounding when extending boxes over page breaks
When a box would break over the edge of a page, its height is extended
to the bottom of that page (per
https://www.w3.org/TR/css-break-3/#box-splitting , primarily to allow
backgrounds and borders to continue to the end of the page).

When this happened, sometimes the values that would be calculated for
the height of the extended element would be rounded *over* the
calculated height that remained on the page, forcing the entire
containing box to wrap to the next page.

Rather than trying to carefully manage the order of operations to try to
be safe in IEEE floats for directions, we apply a small "fudge factor":
if an element fits very nearly (within a thousandth of a pixel) into the
remaining space, it is still accepted.
2022-02-01 18:13:39 -06:00
Guillaume Ayoub
7108a16f87 Add a test about text rotation
Related to #1554.
2022-01-30 14:30:57 +01:00
Guillaume Ayoub
8d19ab4157 Merge branch '54.x' 2022-01-25 15:58:36 +01:00
Guillaume Ayoub
563ee6f98c Handle break-inside: avoid in tr
Fix #1547.
2022-01-25 15:57:58 +01:00
Guillaume Ayoub
4f434343ba Avoid infinite loops with td with break-inside: avoid
Related to #1547.
2022-01-25 12:35:59 +01:00
Guillaume Ayoub
476a8f593b Uncomment passing test 2022-01-24 21:32:33 +01:00
Guillaume Ayoub
51f8a0dc52 Merge branch '54.x' 2022-01-24 16:14:25 +01:00
Guillaume Ayoub
0ae65b8297 Layout positioned boxes in page margins
Fix #1540.
2022-01-24 16:11:18 +01:00
Guillaume Ayoub
d06ad070d5
Merge pull request #1534 from aschmitz/wrap-improvements
Fix `overflow-wrap`, support `word-break: break-all`
2022-01-16 09:31:18 +01:00
Lucie Anglade
cd8a4637aa Related to #1540.
Regression test
2022-01-14 15:26:03 +01:00
Lucie Anglade
f8c9747962 Don’t crash when running elements aren’t ParentBoxes 2022-01-14 15:19:26 +01:00
Guillaume Ayoub
72d05e319f Don’t crash with absolute flex boxes
Fix #1536.
2022-01-10 14:31:49 +01:00
Guillaume Ayoub
a10032c987 Don’t crash with absolute flex boxes
Fix #1536.
2022-01-10 14:31:09 +01:00
aschmitz
480a6ed3bf feat: support word-break: break-all
This adds support for the `break-all` value for `word-break`. The
`keep-all` and `break-word` properties are not yet supported.
2022-01-04 19:08:16 -06:00
aschmitz
439e129561 fix: don't wrap overflow-wrap: anywhere unnecessarily
Previously, if `overflow-wrap: anywhere` (or `break-word`) was set on an
inline element (like an `<a>` or `<span>`) whose first word occurred
towards the end of a line, it would have broken that word, even if doing
so wasn't necessary (and wouldn't have happened were it not for the
wrapping element).

This pipes through a `is_line_start` argument to `split_text_box` that
only allows the break on a word if it's the first word in a line.
2022-01-04 19:03:48 -06:00
Guillaume Ayoub
467748ad0e Handle text-align: inherit 2021-12-28 18:19:29 +01:00
Guillaume Ayoub
810e75b5f4 Handle flex: inherit 2021-12-28 18:09:25 +01:00
Guillaume Ayoub
d4895edae0 Handle flex-flow: inherit 2021-12-28 17:50:58 +01:00
Guillaume Ayoub
6aa5bc8dc1 Handle line-clamp: inherit 2021-12-28 17:48:17 +01:00
Guillaume Ayoub
df28018e92 Handle page-break-inside: inherit 2021-12-28 17:42:13 +01:00
Guillaume Ayoub
86176384fd Handle border-radius: inherit 2021-12-28 17:38:47 +01:00
Guillaume Ayoub
f915ca2938 Handle page-break-after/before: inherit 2021-12-28 17:20:34 +01:00
Guillaume Ayoub
385bb77819 Merge branch 'master' into inherit 2021-12-21 13:08:35 +01:00
Christoph Kepper
bc22f29cb5 #1007 Make 'inherit' value work correctly for word-wrap and overflow-wrap properties 2021-12-21 12:27:46 +01:00
Guillaume Ayoub
8d2c549a82 Update y position when table cells are broken
Fix #1523.
2021-12-20 21:03:58 +01:00
Guillaume Ayoub
ea317e5b94 Fix split tables with border collapse 2021-12-20 14:44:43 +01:00
Guillaume Ayoub
587f235647 Comment failing bug 2021-12-18 20:03:15 +01:00
Guillaume Ayoub
e61422ef72 Remove decorations at the top of broken tables 2021-12-14 15:49:42 +01:00
Guillaume Ayoub
b18b67a241 Handle 'inherit' value in text-decoration
Related to #1007.
2021-12-14 11:30:45 +01:00
Guillaume Ayoub
7a5c285c87 Don’t remove inline block’s trailing space twice
When we calculate the minimum width of an inline block, the size of the
trailing space is already removed by split_first_line. There’s no need to
remove it twice.

We should probably fix split_first_line to remove the trailing space only when
it’s been asked to. But there’s no obvious situation when we want the minimum
width to include trailing spaces, as the minimum size requires line breaks
everywhere, including after each space.

At least, this commit doesn’t remove trailing spaces twice.

Related to #1520.
2021-12-13 13:08:01 +01:00
Guillaume Ayoub
a65ca19bed Add (failing) tests about minimum width with trailing spaces
Related to #1520.
2021-12-13 12:10:48 +01:00
Guillaume Ayoub
6fb0269a36 Add overflow-wrap tests with trailing spaces 2021-12-13 11:20:39 +01:00
Guillaume Ayoub
a27aa37597 Fix overflow-wrap test 2021-12-13 11:16:43 +01:00
aschmitz
1b27388421 Support "overflow-wrap: anywhere"
This supports the `overflow-wrap` value `anywhere`: `anywhere` is like
`break-word`, but the soft breaks it allows *are* considered when
calculating min-content intrinsic sizes.
2021-12-13 02:19:50 -06:00
Guillaume Ayoub
f5d6d54cca Split absolute boxes
Fix #36.
2021-12-12 18:58:04 +01:00
Guillaume Ayoub
21484fafba Merge branch 'master' into footnotes 2021-12-11 17:05:33 +01:00
Guillaume Ayoub
3f596ce21f Fix footnotes for repaginated documents 2021-12-10 17:51:10 +01:00
Guillaume Ayoub
1800bb5ed6 Add test for footnotes margins 2021-12-09 16:40:02 +01:00
Guillaume Ayoub
8cc6b258a0 Handle footnote-policy 2021-12-09 16:20:39 +01:00
Guillaume Ayoub
f54da35dc7 Report footnotes when previous footnotes are already reported 2021-12-08 21:00:21 +01:00
Guillaume Ayoub
7126f1b804 Remove useless color from tests 2021-12-08 20:29:31 +01:00
Lucie Anglade
7c8c291d96 Add reported footnote test 2021-12-08 17:43:19 +01:00
Guillaume Ayoub
5e6b21cec8 Fix last tests for footnotes 2021-12-08 15:35:54 +01:00
Guillaume Ayoub
ed0916d55c Fix more tests for footnotes 2021-12-08 15:16:45 +01:00
Guillaume Ayoub
a702292a1a Fix inline footnotes test 2021-12-08 15:02:46 +01:00
Guillaume Ayoub
6f190a2f20 Add missing underlines and empty strings 2021-12-07 14:46:07 +01:00
Guillaume Ayoub
8ae09175eb Typo 2021-12-06 16:39:25 +01:00
Guillaume Ayoub
d0f30fcb8a Fix tests for floats 2021-12-06 16:14:55 +01:00
Guillaume Ayoub
dd14bb968b Save images in tests when there’s the wrong number of pages 2021-12-06 15:50:55 +01:00
Lucie Anglade
22efdc832b More text in normal flow for absolute/float split tests 2021-12-05 20:08:04 +01:00
Guillaume Ayoub
64797e77f4 Fix test 2021-12-05 19:57:17 +01:00
Guillaume Ayoub
c101e0c6a8 Merge branch 'master' of github.com:Kozea/WeasyPrint 2021-12-05 19:17:05 +01:00
Guillaume Ayoub
379be1e575 Include non-printable characters width during rendering
Fix #1515. Related to #1508.
2021-12-05 19:15:39 +01:00
Lucie Anglade
06fe73d54b Move length check 2021-12-04 23:48:44 +01:00
Lucie Anglade
f0384d1fcf Check if the expected result and the computed one have the same number of pixels. 2021-12-04 17:45:53 +01:00
Lucie Anglade
be71cc6e66 Add xfail on failing tests 2021-12-04 17:44:35 +01:00
Lucie Anglade
7f9503470a Fix expected pixels and add xfails 2021-12-04 17:44:10 +01:00
Lucie Anglade
c761879ade Test absolute split 2021-12-04 16:56:50 +01:00
Lucie Anglade
fcea5f02df Test floats split 2021-12-04 16:56:39 +01:00
Lucie Anglade
2c77f5f2f9 Fix indent 2021-12-04 16:53:50 +01:00
Lucie Anglade
fb12d2ca83 Test floats split 2021-12-04 16:33:54 +01:00
Lucie Anglade
c5f03c2c89 More footnotes tests 2021-11-30 11:24:25 +01:00
Lucie Anglade
d42b0fabfe Some footnotes tests 2021-11-29 16:30:10 +01:00
Guillaume Ayoub
5ce71e48fe Merge branch 'master' of github.com:Kozea/WeasyPrint 2021-11-29 15:08:51 +01:00
Guillaume Ayoub
80b88db154 Don’t crash when the font size is really small
Fix #1499.
2021-11-29 15:08:18 +01:00
Guillaume Ayoub
677b083d78
Merge pull request #1505 from ColinKinloch/woff_cache
Reuse decompressed woff files based on hash
2021-11-29 12:24:43 +01:00
Colin Kinloch
82f98b16ab Correct comment on woff font test 2021-11-28 20:41:27 +00:00
Colin Kinloch
a273b08a59 Fix woff cache read and add woff cache test 2021-11-28 20:30:55 +00:00
Guillaume Ayoub
424f080311 Don’t draw empty glyphs at all
Fix #1508.
2021-11-28 19:47:37 +01:00
Guillaume Ayoub
6a9dac4861 Replace max_position_y by bottom_space
As the bottom of the page is now dynamic (because it changes with footnotes),
passing the max_position_y is difficult: it would require the value to be
passed to layout functions, and returned (possibly updated) by these functions.

The new solution is to store the page bottom in the context, and to update it
when a footnote is included. The new max position y is calculated when needed,
using the updated position of the page bottom.

To handle extra bottom spaces (bottom padding/border/margin of a parent box for
example), a bottom_space parameter is given when needed. This value can be set
to -inf when we don’t want to take care of the page bottom (that’s equivalent
to max_position_y=inf).
2021-11-27 17:01:16 +01:00
Colin Kinloch
4549913644 Add test to make sure woff fonts load and fix typo 2021-11-24 20:10:28 +00:00
Guillaume Ayoub
fe5fa64f57 Display footnotes at the bottom of the page 2021-11-23 13:37:53 +01:00
Guillaume Ayoub
1c3fd972bd Store footnotes in the layout context 2021-11-19 11:39:47 +01:00
Guillaume Ayoub
aafb119e29 Copy boxes when using them in stacking contexts
If we don’t copy the boxes, rendering pages twice will fail because creating
stacking contexts can change the boxes’ children.

Fix #1473.
2021-11-14 19:41:10 +01:00
Guillaume Ayoub
58c9dbc231 Add an option to return split images when testing PNGs 2021-11-14 19:41:04 +01:00
Guillaume Ayoub
837d64111b Use the BATCH mode of ghostscript
Without this mode, we get the "GS>" prompt at the end of the standard output.
2021-11-14 19:27:34 +01:00
Guillaume Ayoub
046f27bf98 Split blocks in blocks when possible
Related to #1476.
2021-11-14 13:25:04 +01:00
Guillaume Ayoub
f46e254107 Fix column height with column-span content
Fix #1094.
2021-11-10 21:20:30 +01:00
Guillaume Ayoub
ce44a72318 Fix images embedded from multiple pages
Fix #1486.
2021-11-05 21:59:09 +01:00
Guillaume Ayoub
d62974e0b4 Simplify reference creation for API test
This change also uses the same source file for reference and tests, allowing
identifiers to be related to URLs.

Related to #1486.
2021-11-05 21:33:47 +01:00
Guillaume Ayoub
bd753560b4 Remove float width from inline box available width 2021-10-29 16:06:13 +02:00
Guillaume Ayoub
511033471a Merge remote-tracking branch 'origin/53.x' 2021-10-29 16:04:02 +02:00
Lucie Anglade
abd54c4bd4 Set SVG ratio when width and height are 0 2021-10-28 11:21:37 +02:00
Guillaume Ayoub
482dc6bf1e Merge branch '53.x' 2021-10-13 22:16:07 +02:00
Guillaume Ayoub
0524421ec1 Only enable letter- and word-spacing when needed
Enabling letter-spacing with a value of 0 breaks ligatures, and probably other
typography features.

Fix #1469.
2021-10-13 22:11:58 +02:00
Guillaume Ayoub
833afb68df Remove original_text attribute
This "hack" was introduced to ignore the text-transform property for bookmarks.
Now that the whitespace management logic is done after the box creation (just
before building the bookmark label), we can do the same for the text
transformation (just after building the bookmark label).

Related to #607 and #137.
2021-10-13 21:26:49 +02:00
Guillaume Ayoub
e5beff677a Process whitespaces as soon as box children are set
This early process enables properties with <content-list> values (string-set,
bookmark-label, etc.) to be defined using whitespace-processed strings.

Fix #607.
2021-10-13 09:48:39 +02:00
Guillaume Ayoub
313fb3a7f0 Remove deprecated options 2021-09-22 18:51:49 +02:00
Guillaume Ayoub
df25719cdb Fix background size of pages with a bleed margin
Fix #1446.
2021-09-18 18:37:37 +02:00
Guillaume Ayoub
0cc24e5a18 Fix background size of pages with a bleed margin
Fix #1446.
2021-09-18 18:34:12 +02:00
Guillaume Ayoub
35fa9037fd Rename layout files to follow "display" values 2021-09-13 15:37:29 +02:00
Guillaume Ayoub
37af386852 Cache SVG use tags
Fix #1439.
2021-09-11 14:57:47 +02:00
Guillaume Ayoub
f2cf74d31a Merge branch '53.x' 2021-09-07 22:27:21 +02:00
Guillaume Ayoub
3fd70e10b4 Don’t crash when transparent images are used twice in CSS
Fix #1440.
2021-09-07 22:25:46 +02:00
Guillaume Ayoub
85e1ea1043 Don’t use "text-transform"ed text for content-based uses
This solution is far from perfect. What we could do is to have a getter/setter
for the "text" attribute of TextBox using the "original_text" attribute, so
that we’re sure that we change one when we change the other.

But… That would be much more complicated and much slower, only to solve corner
use cases.

Of course, an issue will be open soon, when someone finds one of these cases ;).

Fix #137.
2021-09-06 21:29:25 +02:00
Guillaume Ayoub
17cf6239b5 Fix the "contents" value of bookmark-label 2021-08-31 16:42:26 +02:00
Guillaume Ayoub
31cd0d7233 Fix the "contents" value of bookmark-label 2021-08-31 16:38:51 +02:00
Guillaume Ayoub
d3e39055cf Merge branch '53.x' 2021-08-27 14:48:59 +02:00
Guillaume Ayoub
c51bc60764 Re-add make_bookmark_tree method
Fix #1428.
2021-08-27 14:43:17 +02:00
Guillaume Ayoub
bb29eca337 Transform text-align into shorthand
text-align is now a shorthand, setting text-align-all and text-align-last.

Related to #1389.
2021-08-24 13:27:59 +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
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
f16b4c32d5 Test media queries 2021-08-06 18:38:06 +02:00
Guillaume Ayoub
ebd1064984 Test deprecated -o option 2021-08-06 18:14:13 +02:00
Guillaume Ayoub
143565e08d Test object-fit and object-position 2021-08-06 11:19:47 +02:00
Guillaume Ayoub
ccbe420d35 Fix optimization test 2021-08-04 17:14:52 +02:00
Guillaume Ayoub
c5590dd86d Test CLI optimizations 2021-08-04 16:54:09 +02:00
Guillaume Ayoub
0a1b2e9c64 Remove useless helper 2021-08-04 10:48:50 +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
2a8e23d3c4 Fix tests failing beacause of Ghostscript roundings 2021-07-27 22:55:19 +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
a9cc75d0b9 Remove empty lines 2021-07-23 23:23:00 +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
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
5fba476370 Test and fix text-anchor 2021-07-18 10:09:03 +02:00
Guillaume Ayoub
c7b97fa3bf Handle simple cases of clip-path
Fix #1374.
2021-07-18 09:36:14 +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
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
cef8cf109d Fix and simplify image size management 2021-07-12 15:07:31 +02:00
Guillaume Ayoub
010f40adeb Fix padding for columns 2021-07-11 17:40:02 +02:00
Guillaume Ayoub
a267735f31 Parametrize some tests 2021-06-13 08:12:33 +02: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
a3028945fc Handle visibility and display attributes
Fix #1362.
2021-05-25 15:01:07 +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
b17b08dae7 Don’t crash with ex units in spacing properties 2021-05-07 16:38:51 +02:00
Guillaume Ayoub
2d19becf19 Improve SVG support 2021-04-30 18:13:08 +02:00
Guillaume Ayoub
becd494f91 Add an option to optimize fonts
Fix #359.
2021-04-28 14:55:52 +02:00
Guillaume Ayoub
c931d1639b Remove useless xfail 2021-04-28 14:45:53 +02:00
Guillaume Ayoub
3ec32732aa Fix gradients and tests 2021-04-26 17:36:18 +02:00
Guillaume Ayoub
d1c1e9e69f Fix tests 2021-04-26 11:31:07 +02:00
Guillaume Ayoub
eae3540c55 Merge branch 'pydyfsvg' 2021-04-22 12:29:04 +02:00
Guillaume Ayoub
8cf54c56c6 Remove TODOS about PDF checks in tests
Testing PNG rendering is enough
2021-04-20 15:40:39 +02:00
Guillaume Ayoub
a90119d14a Remove TODO 2021-04-20 15:36:30 +02:00
Guillaume Ayoub
fdcdcef006 Fix test 2021-04-20 08:48:44 +02:00
Guillaume Ayoub
dc861c785a Add more tests for SVG images 2021-04-19 17:52:25 +02:00
Guillaume Ayoub
111191f7bc Rename folders and imports in tests 2021-04-19 17:15:53 +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
Lucie Anglade
f27a37c943 Test paths A a 2021-04-18 17:15:56 +02:00
Guillaume Ayoub
541ed24472 Test SVG images 2021-04-18 16:01:26 +02:00
Guillaume Ayoub
c3e05dd510 Fix test for Ss path 2021-04-17 18:20:54 +02:00
Lucie Anglade
89808b3aac Merge branch 'pydyfsvg' of github.com:Kozea/WeasyPrint into pydyfsvg 2021-04-17 18:16:31 +02:00
Lucie Anglade
ac46d68eaf Test paths Q q T t 2021-04-17 18:16:22 +02:00
Guillaume Ayoub
6391139040 Add tests for text 2021-04-17 18:15:26 +02:00
Lucie Anglade
9f1c7182f8 Fix error message 2021-04-17 18:09:27 +02:00
Lucie Anglade
6308c65b16 Test paths C c S s 2021-04-17 12:49:28 +02:00
Lucie Anglade
acb2076a7a Test paths fill 2021-04-17 11:35:57 +02:00
Guillaume Ayoub
84f945d396 Fix userSpaceOnUse for gradients 2021-04-16 11:21:46 +02:00
Lucie Anglade
fd8b325bb6 Test basic paths 2021-04-15 18:56:30 +02:00
Lucie Anglade
6a0eb9b475 Test radial gradients 2021-04-15 11:58:26 +02:00
Lucie Anglade
838bb2f019 Maybe fix expected result for radial gradient 2021-04-14 23:14:01 +02:00
Lucie Anglade
97d2826acf Test basic radial gradient 2021-04-14 22:39:57 +02:00