Skip to content

Commit b2249c4

Browse files
juulsAqu1ck
authored andcommitted
Add fillrule to text properties
1 parent 44705ef commit b2249c4

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

DATAFORMAT.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ attribute.
258258
// 0: justify center
259259
// 1: justify right/bot
260260
"justify": [horizontal, vertical],
261+
// Either the thickness or the fillrule must be used
261262
"thickness": thickness,
263+
"fillrule": "nonzero" | "evenodd",
262264
"attr": [
263265
// may include none, one or both
264266
"italic", "mirrored"

InteractiveHtmlBom/ecad/schema/genericjsonpcbdata_v1.schema

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,20 @@
443443
"properties": {
444444
"svgpath": { "type": "string" },
445445
"thickness": { "type": "number" },
446+
"fillrule": {
447+
"type": "string",
448+
"enum": [
449+
"nonzero",
450+
"evenodd"
451+
]
452+
},
446453
"ref": { "type": "integer" , "const": 1 },
447454
"val": { "type": "integer" , "const": 1 }
448455
},
449-
"required": [
450-
"svgpath",
451-
"thickness"
456+
"required": ["svgpath"],
457+
"oneOf": [
458+
{ "required": ["thickness"] },
459+
{ "required": ["fillrule"] }
452460
],
453461
"title": "DrawingText"
454462
},

InteractiveHtmlBom/web/render.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@ function drawText(ctx, text, color) {
2424
ctx.strokeStyle = color;
2525
ctx.lineCap = "round";
2626
ctx.lineJoin = "round";
27-
ctx.lineWidth = text.thickness;
2827
if ("svgpath" in text) {
29-
ctx.stroke(new Path2D(text.svgpath));
30-
ctx.restore();
31-
return;
28+
if ("thickness" in text) {
29+
ctx.lineWidth = text.thickness;
30+
ctx.stroke(new Path2D(text.svgpath));
31+
ctx.restore();
32+
return;
33+
}
34+
if ("fillrule" in text) {
35+
ctx.fill(new Path2D(text.svgpath), text.fillrule);
36+
ctx.restore();
37+
return;
38+
}
3239
}
3340
if ("polygons" in text) {
3441
ctx.fill(getPolygonsPath(text));

0 commit comments

Comments
 (0)