From b42b0e85fa2220a5083f64383aed43de73788c0c Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 24 Apr 2022 20:05:29 +0200 Subject: Rectify latest cairo SVG export It seems Cairo got updated and its SVG export is now broken in a new and exciting way. Now it exports documents with dimensionless w/h. The issue with that is that Cairo thinks that means point @ 72 pt / inch, but everyone else including the actual svg spec interpret that as raw document units or pixels, AFAICT completely breaking dpi scaling in common viewers. Since we have to mess with Cairo's SVG files anyway, we just fix this as well by re-writing the broken w/h into physical units according to a hardcoded conversion factor that matches cairo's hardcoded scale. --- gerbonara/tests/test_rs274x.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gerbonara/tests/test_rs274x.py') diff --git a/gerbonara/tests/test_rs274x.py b/gerbonara/tests/test_rs274x.py index 51fb910..5a3916a 100644 --- a/gerbonara/tests/test_rs274x.py +++ b/gerbonara/tests/test_rs274x.py @@ -473,6 +473,8 @@ def test_svg_export(reference, tmpfile): ref_svg = tmpfile('Reference export', '.svg') ref_png = tmpfile('Reference render', '.png') gerbv_export(reference, ref_svg, origin=bounds[0], size=bounds[1], fg='#000000', bg='#ffffff') + with svg_soup(ref_svg) as soup: + cleanup_gerbv_svg(soup) svg_to_png(ref_svg, ref_png, dpi=300, bg='white') out_png = tmpfile('Output render', '.png') -- cgit