Skip to content

Commit 0bf986c

Browse files
committed
Fix lineWidth reset in rendering, update compatibility with nightly
Fixes #531
1 parent b2249c4 commit 0bf986c

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

DATAFORMAT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ attribute.
260260
"justify": [horizontal, vertical],
261261
// Either the thickness or the fillrule must be used
262262
"thickness": thickness,
263+
// fillrule is only supported for svgpath
263264
"fillrule": "nonzero" | "evenodd",
264265
"attr": [
265266
// may include none, one or both

InteractiveHtmlBom/ecad/kicad.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ def __init__(self, file_name, config, logger, board=None):
3131
if self.board is None:
3232
self.board = pcbnew.LoadBoard(self.file_name) # type: pcbnew.BOARD
3333
if hasattr(self.board, 'GetModules'):
34-
self.footprints = list(self.board.GetModules()) # type: list[pcbnew.MODULE]
34+
# type: list[pcbnew.MODULE]
35+
self.footprints = list(self.board.GetModules())
3536
else:
36-
self.footprints = list(self.board.GetFootprints()) # type: list[pcbnew.FOOTPRINT]
37+
# type: list[pcbnew.FOOTPRINT]
38+
self.footprints = list(self.board.GetFootprints())
3739
self.font_parser = FontParser()
3840

3941
def get_extra_field_data(self, file_name):
@@ -273,7 +275,8 @@ def parse_text(self, d):
273275
"svgpath": create_path(lines)
274276
}
275277
elif hasattr(d, 'GetEffectiveTextShape'):
276-
shape = d.GetEffectiveTextShape(False) # type: pcbnew.SHAPE_COMPOUND
278+
# type: pcbnew.SHAPE_COMPOUND
279+
shape = d.GetEffectiveTextShape(False)
277280
segments = []
278281
polygons = []
279282
for s in shape.GetSubshapes():
@@ -426,7 +429,7 @@ def get_all_drawings(self):
426429
for d in f.GraphicalItems():
427430
drawings.append((d.GetClass(), d))
428431
if hasattr(f, "GetFields"):
429-
fields = f.GetFields() # type: list[pcbnew.PCB_FIELD]
432+
fields = f.GetFields() # type: list[pcbnew.PCB_FIELD]
430433
for field in fields:
431434
if field.IsReference() or field.IsValue():
432435
continue
@@ -450,11 +453,15 @@ def parse_pad(self, pad):
450453
custom_padstack = False
451454
outer_layers = [(pcbnew.F_Cu, "F"), (pcbnew.B_Cu, "B")]
452455
if hasattr(pad, 'Padstack'):
453-
padstack = pad.Padstack() # type: pcbnew.PADSTACK
456+
padstack = pad.Padstack() # type: pcbnew.PADSTACK
454457
layers_set = list(padstack.LayerSet().Seq())
458+
if hasattr(pcbnew, "UNCONNECTED_LAYER_MODE_REMOVE_ALL"):
459+
ULMRA = pcbnew.UNCONNECTED_LAYER_MODE_REMOVE_ALL
460+
else:
461+
ULMRA = padstack.UNCONNECTED_LAYER_MODE_REMOVE_ALL
455462
custom_padstack = (
456-
padstack.Mode() != padstack.MODE_NORMAL or \
457-
padstack.UnconnectedLayerMode() == padstack.UNCONNECTED_LAYER_MODE_REMOVE_ALL
463+
padstack.Mode() != padstack.MODE_NORMAL or
464+
padstack.UnconnectedLayerMode() == ULMRA
458465
)
459466
else:
460467
layers_set = list(pad.GetLayerSet().Seq())

InteractiveHtmlBom/web/render.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ function drawText(ctx, text, color) {
2828
if ("thickness" in text) {
2929
ctx.lineWidth = text.thickness;
3030
ctx.stroke(new Path2D(text.svgpath));
31-
ctx.restore();
32-
return;
33-
}
34-
if ("fillrule" in text) {
31+
} else if ("fillrule" in text) {
3532
ctx.fill(new Path2D(text.svgpath), text.fillrule);
36-
ctx.restore();
37-
return;
3833
}
34+
ctx.restore();
35+
return;
3936
}
37+
ctx.lineWidth = text.thickness;
4038
if ("polygons" in text) {
4139
ctx.fill(getPolygonsPath(text));
4240
ctx.restore();

0 commit comments

Comments
 (0)