Don't use a pattern when drawing backgrounds for no-repeat background images #2190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one's a bit weird, so feel free to let me know if this doesn't feel suitable to upstream or if you would prefer a different approach.
WeasyPrint uses PDF patterns for background images, which is a reasonable choice. However, a PDF viewer I frequently use, Preview.app on MacOS, doesn't handle vector images in patterns as well as it does when those images are drawn not via a pattern, leading to unnecessary pixelation when zooming in. Adobe Acrobat Reader doesn't have this issue, so I think this is just a shortcoming of Preview.app. But, at least when the background-image is no-repeat, there doesn't seem to be any advantage to having it in a pattern.
Thus, this pull request draws the background image directly (without a pattern) in the case where the background image is no-repeat in both directions, while leaving other cases unchanged. This is sufficient for my use-case. While it would be possible to avoid using a pattern in more cases by drawing the image directly repeatedly, that would add complexity and so I wasn't sure whether it would be desirable.
Since this change shouldn't change how the resulting PDF appears visually in general, I wasn't sure how to write a meaningful regression test. Attached are screenshots of the same source zoomed in via Preview.app, to show you what I'm talking about.