summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/tests
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-01-23 14:41:59 +0100
committerjaseg <git@jaseg.de>2022-01-23 14:41:59 +0100
commit4ed83580963669e29305c45b104b78a22ef3e86c (patch)
treeb120256fdd0df45340e0c5d8ae61496f3613ae05 /gerbonara/gerber/tests
parentdeb2bb2bbfc13e6dce8adf493221a4fe4929a344 (diff)
downloadgerbonara-4ed83580963669e29305c45b104b78a22ef3e86c.tar.gz
gerbonara-4ed83580963669e29305c45b104b78a22ef3e86c.tar.bz2
gerbonara-4ed83580963669e29305c45b104b78a22ef3e86c.zip
Fix a whole bunch of SVG export bugs
Diffstat (limited to 'gerbonara/gerber/tests')
-rw-r--r--gerbonara/gerber/tests/image_support.py4
-rw-r--r--gerbonara/gerber/tests/test_rs274x.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/gerbonara/gerber/tests/image_support.py b/gerbonara/gerber/tests/image_support.py
index c43f7b6..a50e243 100644
--- a/gerbonara/gerber/tests/image_support.py
+++ b/gerbonara/gerber/tests/image_support.py
@@ -67,6 +67,9 @@ def svg_to_png(in_svg, out_png, dpi=100, bg='black'):
to_gerbv_svg_units = lambda val, unit='mm': val*72 if unit == 'inch' else val/25.4*72
def gerbv_export(in_gbr, out_svg, export_format='svg', origin=(0, 0), size=(6, 6), fg='#ffffff', bg='#000000', override_unit_spec=None):
+ # NOTE: gerbv seems to always export 'clear' polarity apertures as white, irrespective of --foreground, --background
+ # and project file color settings.
+ # TODO: File issue upstream.
with tempfile.NamedTemporaryFile('w') as f:
if override_unit_spec:
units, zeros, digits = override_unit_spec
@@ -92,6 +95,7 @@ def gerbv_export(in_gbr, out_svg, export_format='svg', origin=(0, 0), size=(6, 6
'--border=0',
f'--origin={x:.6f}x{y:.6f}', f'--window_inch={w:.6f}x{h:.6f}',
f'--background={bg}',
+ f'--foreground={fg}',
'-o', str(out_svg), '-p', f.name]
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
diff --git a/gerbonara/gerber/tests/test_rs274x.py b/gerbonara/gerber/tests/test_rs274x.py
index bf49fe8..06150de 100644
--- a/gerbonara/gerber/tests/test_rs274x.py
+++ b/gerbonara/gerber/tests/test_rs274x.py
@@ -433,14 +433,14 @@ def test_svg_export(reference, tmpfile):
out_svg = tmpfile('Output', '.svg')
with open(out_svg, 'w') as f:
- f.write(str(grb.to_svg(force_bounds=bounds, arg_unit='inch', color='white')))
+ f.write(str(grb.to_svg(force_bounds=bounds, arg_unit='inch', fg='black', bg='white')))
# NOTE: Instead of having gerbv directly export a PNG, we ask gerbv to output SVG which we then rasterize using
# resvg. We have to do this since gerbv's built-in cairo-based PNG export has severe aliasing issues. In contrast,
# using resvg for both allows an apples-to-apples comparison of both results.
ref_svg = tmpfile('Reference export', '.svg')
ref_png = tmpfile('Reference render', '.png')
- gerbv_export(reference, ref_svg, origin=bounds[0], size=bounds[1])
+ gerbv_export(reference, ref_svg, origin=bounds[0], size=bounds[1], fg='#000000', bg='#ffffff')
svg_to_png(ref_svg, ref_png, dpi=72) # make dpi match Cairo's default
out_png = tmpfile('Output render', '.png')
@@ -471,7 +471,7 @@ def test_bounding_box(reference, tmpfile):
grb = GerberFile.open(reference)
out_svg = tmpfile('Output', '.svg')
with open(out_svg, 'w') as f:
- f.write(str(grb.to_svg(margin=margin, arg_unit='inch', color='white')))
+ f.write(str(grb.to_svg(margin=margin, arg_unit='inch', fg='white', bg='black')))
out_png = tmpfile('Render', '.png')
svg_to_png(out_svg, out_png, dpi=dpi)