Dotted borders require a lot of PDF paths
Tested under windows 11 with Weasyprint 65.1 and 66
66: 33.6 KB 65.1: 3.74 KB
<!DOCTYPE html>
<html>
<head>
<style>
body {
border: 1px dotted black;
}
</style>
</head>
<body>
</body>
</html>
Hi!
You’re right, these dots takes a lot of place. The change happened because of #2265: dotted lines in CSS must be circles, not squares. There’s an operator to draw a rectangle in PDF, but not a circle, so we have to use Bézier curves instead, and they require a lot of coordinates (24 numbers instead of 4 for a rectangle).
We could try different strategies to avoid that. One is to use stroked lines instead of filled circles, as playing with line cap styles gives the possibility to draw circles. But with rounded corners, different styles for different sides, and border images, it quickly becomes a nightmare.
Prince also creates very large documents (actually sometimes larger than WP) with dotted lines and rounded corners, with Bézier curves just like us, so I suspect there’s no other good solution. But they use stroked lines as a smart shortcut when there’s no rounded corner.
If someone finds an efficient and maintainable solution, I’d be happy to talk about it!
Ah, that is is fair. I guess the issue should stay open then?
I don’t persoonally mind, just accidentally encountered it while investigating the problem in the other ticket, and thought I should report it ;)
I guess the issue should stay open then?
Yes, we can do better. That’s actually a good way to dive into WeasyPrint’s code for anyone who likes geometry. 😄
I don’t persoonally mind, just accidentally encountered it while investigating the problem in the other ticket, and thought I should report it ;)
Thanks!