Closed 13thirteen closed 8 months ago
Thank you for raising your first issue! Your help to improve svglib is much appreciated!
Thanks for this report! Just to confirm I'm seeing the same effect for reportlab 3.5.68, svglib 1.4.1, and Python 3.10.6 on macOS 13.5.1. Might be a simple conversion buglet. Will check...
It's embarrassing, but the pt unit in these tests is off by a factor of 1.25, and 1 px should be 1.3333333333333 pt. Will be fixed in Svg2RlgAttributeConverter.convertLength()...
@13thirteen This feature branch should fix your issue: https://github.com/deeplook/svglib/tree/fix_units_pt_px. Can you please verify and give premission to add your SVG sample to the test cases?
Thank you for the fix!
Yes, I can confirm that the PDF generated with the code in the feature branch looks correct:
Please feel free to use the SVG snippet in the tests.
Something is wrong with units
px
(pixels) andpt
(points).The following SVG file contains text and red bars of the same size in different units:
From MDN: Absolute Length Units:
Which gives
96px
=2.54cm
=25.4mm
=1in
=6pc
=72pt
All text should have the same font size. All bars should have the same length.
The following are screenshots of the SVG and the PDF generated by svglib opened in Firefox: The SVG looks correct:
The generated PDF looks wrong, the first and last units
px
andpt
seem too big:Tested with svglib 1.5.1, reportlab 4.0.5, Python 3.11.5, Windows 10