From a4fe7ed4d5d4694e94abeaf94b3c3d970ffc4440 Mon Sep 17 00:00:00 2001 From: bimakw <51526537+bimakw@users.noreply.github.com> Date: Sun, 1 Feb 2026 17:12:03 +0700 Subject: [PATCH 1/6] feat: map knockout props in SilkscreenText component Add support for knockout silkscreen text by mapping isKnockout and knockoutPadding props to circuit-json is_knockout and knockout_padding fields. - Map isKnockout prop to is_knockout in pcb_silkscreen_text - Map knockoutPaddingLeft/Right/Top/Bottom to knockout_padding object - Add test for knockout silkscreen text Part of tscircuit/tscircuit#770 --- .../primitive-components/SilkscreenText.ts | 18 +++++++++++++ .../silkscreen-text-knockout-pcb.snap.svg | 1 + .../silkscreen-text-knockout.test.tsx | 26 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg create mode 100644 tests/components/primitive-components/silkscreen-text-knockout.test.tsx diff --git a/lib/components/primitive-components/SilkscreenText.ts b/lib/components/primitive-components/SilkscreenText.ts index 3232c8446..6c084fb7d 100644 --- a/lib/components/primitive-components/SilkscreenText.ts +++ b/lib/components/primitive-components/SilkscreenText.ts @@ -67,6 +67,22 @@ export class SilkscreenText extends PrimitiveComponent< this._footprinterFontSize ?? 1 + // Build knockout padding object if any padding props are set + const hasKnockoutPadding = + props.knockoutPaddingLeft !== undefined || + props.knockoutPaddingRight !== undefined || + props.knockoutPaddingTop !== undefined || + props.knockoutPaddingBottom !== undefined + + const knockoutPadding = hasKnockoutPadding + ? { + left: props.knockoutPaddingLeft ?? 0, + right: props.knockoutPaddingRight ?? 0, + top: props.knockoutPaddingTop ?? 0, + bottom: props.knockoutPaddingBottom ?? 0, + } + : undefined + for (const layer of targetLayers) { const pcb_silkscreen_text = db.pcb_silkscreen_text.insert({ anchor_alignment: props.anchorAlignment, @@ -82,6 +98,8 @@ export class SilkscreenText extends PrimitiveComponent< pcb_component_id: container.pcb_component_id!, subcircuit_id: subcircuit?.subcircuit_id ?? undefined, pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined, + is_knockout: props.isKnockout, + knockout_padding: knockoutPadding, }) this.pcb_silkscreen_text_ids.push( pcb_silkscreen_text.pcb_silkscreen_text_id, diff --git a/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg b/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg new file mode 100644 index 000000000..5349d18f6 --- /dev/null +++ b/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg @@ -0,0 +1 @@ +KNOCKOUT \ No newline at end of file diff --git a/tests/components/primitive-components/silkscreen-text-knockout.test.tsx b/tests/components/primitive-components/silkscreen-text-knockout.test.tsx new file mode 100644 index 000000000..03d7a87ef --- /dev/null +++ b/tests/components/primitive-components/silkscreen-text-knockout.test.tsx @@ -0,0 +1,26 @@ +import { test, expect } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +test("silkscreen text with knockout", () => { + const { circuit } = getTestFixture() + + circuit.add( + + + , + ) + + circuit.render() + + const silkscreenTexts = circuit.db.pcb_silkscreen_text.list() + expect(silkscreenTexts.length).toBe(1) + expect(silkscreenTexts[0]?.is_knockout).toBe(true) + + expect(circuit).toMatchPcbSnapshot(import.meta.path) +}) From 05a43eb314c4a7fa3c21b04329d3f399e860a1c4 Mon Sep 17 00:00:00 2001 From: bimakw <51526537+bimakw@users.noreply.github.com> Date: Tue, 3 Feb 2026 15:24:52 +0700 Subject: [PATCH 2/6] test: update snapshots for knockout silkscreen fields --- .../normal-components/pin-header-pcbOrientation.test.tsx | 2 ++ .../repro57-silkscreen-rotation-counter-clockwise.test.tsx | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tests/components/normal-components/pin-header-pcbOrientation.test.tsx b/tests/components/normal-components/pin-header-pcbOrientation.test.tsx index 69009df54..80d91af99 100644 --- a/tests/components/normal-components/pin-header-pcbOrientation.test.tsx +++ b/tests/components/normal-components/pin-header-pcbOrientation.test.tsx @@ -29,6 +29,8 @@ test("pinheader pcbOrientation vertical places pins vertically", () => { "ccw_rotation": -90, "font": "tscircuit2024", "font_size": 0.7, + "is_knockout": undefined, + "knockout_padding": undefined, "layer": "top", "pcb_component_id": "pcb_component_0", "pcb_group_id": undefined, diff --git a/tests/repros/repro57-silkscreen-rotation-counter-clockwise.test.tsx b/tests/repros/repro57-silkscreen-rotation-counter-clockwise.test.tsx index 45933aadd..f1ead1dec 100644 --- a/tests/repros/repro57-silkscreen-rotation-counter-clockwise.test.tsx +++ b/tests/repros/repro57-silkscreen-rotation-counter-clockwise.test.tsx @@ -36,6 +36,8 @@ test("rotate silkscreen text ccw", async () => { "ccw_rotation": 90, "font": "tscircuit2024", "font_size": 0.5760000000000001, + "is_knockout": undefined, + "knockout_padding": undefined, "layer": "top", "pcb_component_id": "pcb_component_0", "pcb_group_id": undefined, @@ -53,6 +55,8 @@ test("rotate silkscreen text ccw", async () => { "ccw_rotation": 90, "font": "tscircuit2024", "font_size": 0.5760000000000001, + "is_knockout": undefined, + "knockout_padding": undefined, "layer": "top", "pcb_component_id": "pcb_component_0", "pcb_group_id": undefined, @@ -70,6 +74,8 @@ test("rotate silkscreen text ccw", async () => { "ccw_rotation": 90, "font": "tscircuit2024", "font_size": 0.7, + "is_knockout": undefined, + "knockout_padding": undefined, "layer": "top", "pcb_component_id": "pcb_component_0", "pcb_group_id": undefined, From c92b39e226796d85973ac88542d637c4e45f6179 Mon Sep 17 00:00:00 2001 From: bimakw <51526537+bimakw@users.noreply.github.com> Date: Fri, 6 Feb 2026 22:01:05 +0700 Subject: [PATCH 3/6] fix: update circuit-to-svg to 0.0.327 and regenerate knockout snapshot Updated dependency to include merged knockout silkscreen rendering. Snapshot now shows actual knockout effect with SVG mask. --- package.json | 2 +- .../__snapshots__/silkscreen-text-knockout-pcb.snap.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41bcb236e..49ce13633 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "circuit-json-to-gltf": "^0.0.62", "circuit-json-to-simple-3d": "^0.0.9", "circuit-json-to-spice": "^0.0.33", - "circuit-to-svg": "^0.0.325", + "circuit-to-svg": "^0.0.327", "concurrently": "^9.1.2", "connectivity-map": "^1.0.0", "debug": "^4.3.6", diff --git a/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg b/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg index 5349d18f6..2bf95a92c 100644 --- a/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg +++ b/tests/components/primitive-components/__snapshots__/silkscreen-text-knockout-pcb.snap.svg @@ -1 +1 @@ -KNOCKOUT \ No newline at end of file + \ No newline at end of file From 60ad78ea087b698019106b1a8e35f3514dd83853 Mon Sep 17 00:00:00 2001 From: bimakw <51526537+bimakw@users.noreply.github.com> Date: Fri, 6 Feb 2026 22:07:37 +0700 Subject: [PATCH 4/6] test: regenerate all snapshots for circuit-to-svg 0.0.327 Schematic SVG output changed slightly with the new circuit-to-svg version. All 780 tests pass with updated snapshots. --- ...components-display-name-schematic.snap.svg | 4 +- ...-schematic-manual-edits-schematic.snap.svg | 4 +- .../capacitor-polarized-schematic.snap.svg | 4 +- ...apacitor-schOrientation-schematic.snap.svg | 4 +- ...-crossings-simplified-1-schematic.snap.svg | 16 +-- ...lex-schematic-crossings-schematic.snap.svg | 44 ++++---- ...without-portarrangement-schematic.snap.svg | 20 ++-- ...est.tsx-crystal-default-schematic.snap.svg | 4 +- ...st.tsx-crystal-four-pin-schematic.snap.svg | 4 +- ...est.tsx-crystal-two-pin-schematic.snap.svg | 4 +- .../current-source-schematic.snap.svg | 28 ++--- .../diode-variants-schematic.snap.svg | 4 +- ...-connected-pins-numbers-schematic.snap.svg | 4 +- .../led-variants-schematic.snap.svg | 4 +- .../potentiometer-schematic.snap.svg | 2 +- ...tton-pin-configurations-schematic.snap.svg | 4 +- ...button-schRotation-grid-schematic.snap.svg | 4 +- .../resonator-schematic.snap.svg | 4 +- .../rotated-components-schematic.snap.svg | 4 +- .../solderjumper-circuit-schematic.snap.svg | 8 +- .../solderjumper-schematic.snap.svg | 4 +- .../__snapshots__/switch-schematic.snap.svg | 4 +- ...ource-display-rotations-schematic.snap.svg | 4 +- .../voltage-source-schematic.snap.svg | 16 +-- .../netlabel-center-schematic.snap.svg | 4 +- ...atic-crossing-rendering-schematic.snap.svg | 12 +-- ...hematic-neg-schRotation-schematic.snap.svg | 4 +- .../multiple-net-labels-schematic.snap.svg | 8 +- ...ample10-schDisplayLabel-schematic.snap.svg | 4 +- .../example11-net-symbol-schematic.snap.svg | 12 +-- ...-schematic-sel-netlabel-schematic.snap.svg | 28 ++--- .../example28-elbow-schematic.snap.svg | 12 +-- ...minimize-trace-crossing-schematic.snap.svg | 100 +++++++++--------- .../example4-kicad-schematic.snap.svg | 4 +- ...example5-simple-circuit-schematic.snap.svg | 12 +-- ...ulator-with-connections-schematic.snap.svg | 16 +-- .../schematic-flex-schematic.snap.svg | 4 +- .../group-match-adapt3-schematic.snap.svg | 16 +-- .../group-match-adapt7-schematic.snap.svg | 12 +-- ...groups-autolayout-issue-schematic.snap.svg | 4 +- ...e-regulator-match-adapt-schematic.snap.svg | 16 +-- ...pice-analysis01-switch-simulation.snap.svg | 24 ++--- ...ysis02-boost-converter-simulation.snap.svg | 24 ++--- ...-half-bridge-rectifier-simulation.snap.svg | 18 ++-- ...-full-bridge-rectifier-simulation.snap.svg | 24 ++--- ...lysis05-buck-converter-simulation.snap.svg | 26 ++--- ...ysis01-platform-config-simulation.snap.svg | 16 +-- ...ysis02-boost-converter-simulation.snap.svg | 24 ++--- ...arging-voltage-divider-simulation.snap.svg | 18 ++-- ...ge-divider-custom-time-simulation.snap.svg | 18 ++-- ...chematic-border-padding-schematic.snap.svg | 8 +- .../group-schematic-border-schematic.snap.svg | 8 +- ...tchpack-respects-margin-schematic.snap.svg | 4 +- ...chematic-matchpack-test-schematic.snap.svg | 16 +-- .../__snapshots__/index-schematic.snap.svg | 40 +++---- ...o13-schematic-trace-hop-schematic.snap.svg | 12 +-- ...double-schematic-traces-schematic.snap.svg | 12 +-- ...pro15-trace-into-symbol-schematic.snap.svg | 8 +- ...repro20-internal-jumper-schematic.snap.svg | 4 +- ...schematic-trace-overlap-schematic.snap.svg | 12 +-- ...-e2e-pack-and-schematic-schematic.snap.svg | 24 ++--- ...5-pinheader-connections-schematic.snap.svg | 12 +-- .../repro46-automatic-sch-schematic.snap.svg | 16 +-- ...c-trace-routing-failure-schematic.snap.svg | 12 +-- ...47-switch-matrix-diodes-schematic.snap.svg | 16 +-- .../repro48-555-timer-schematic.snap.svg | 24 ++--- ...49-same-net-not-combine-schematic.snap.svg | 8 +- .../repro5-schematic-schematic.snap.svg | 8 +- ...0-decoupling-capacitors-schematic.snap.svg | 24 ++--- ...matic-trace-net-jumping-schematic.snap.svg | 12 +-- ...box-rotation-autolayout-schematic.snap.svg | 8 +- ...pro84_schematic_pin_out-schematic.snap.svg | 36 +++---- ...repro10-usbc-flashlight-schematic.snap.svg | 16 +-- 73 files changed, 501 insertions(+), 501 deletions(-) diff --git a/tests/components/normal-components/__snapshots__/all-components-display-name-schematic.snap.svg b/tests/components/normal-components/__snapshots__/all-components-display-name-schematic.snap.svg index df635f58d..61f40a628 100644 --- a/tests/components/normal-components/__snapshots__/all-components-display-name-schematic.snap.svg +++ b/tests/components/normal-components/__snapshots__/all-components-display-name-schematic.snap.svg @@ -1,4 +1,4 @@ --2,-1-2,0-2,1-2,2-2,3-2,4-2,5-2,6-2,7-2,8-2,9-2,10-2,11-2,12-2,13-2,14-2,15-2,16-2,17-2,18-2,19-1,-1-1,0-1,1-1,2-1,3-1,4-1,5-1,6-1,7-1,8-1,9-1,10-1,11-1,12-1,13-1,14-1,15-1,16-1,17-1,18-1,190,-10,00,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,191,-11,01,11,21,31,41,51,61,71,81,91,101,111,121,131,141,151,161,171,181,192,-12,02,12,22,32,42,52,62,72,82,92,102,112,122,132,142,152,162,172,182,193,-13,03,13,23,33,43,53,63,73,83,93,103,113,123,133,143,153,163,173,183,194,-14,04,14,24,34,44,54,64,74,84,94,104,114,124,134,144,154,164,174,184,195,-15,05,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,196,-16,06,16,26,36,46,56,66,76,86,96,106,116,126,136,146,156,166,176,186,197,-17,07,17,27,37,47,57,67,77,87,97,107,117,127,137,147,157,167,177,187,198,-18,08,18,28,38,48,58,68,78,88,98,108,118,128,138,148,158,168,178,188,199,-19,09,19,29,39,49,59,69,79,89,99,109,119,129,139,149,159,169,179,189,1910,-110,010,110,210,310,410,510,610,710,810,910,1010,1110,1210,1310,1410,1510,1610,1710,1810,1911,-111,011,111,211,311,411,511,611,711,811,911,1011,1111,1211,1311,1411,1511,1611,1711,1811,1912,-112,012,112,212,312,412,512,612,712,812,912,1012,1112,1212,1312,1412,1512,1612,1712,1812,1913,-113,013,113,213,313,413,513,613,713,813,913,1013,1113,1213,1313,1413,1513,1613,1713,1813,1914,-114,014,114,214,314,414,514,614,714,814,914,1014,1114,1214,1314,1414,1514,1614,1714,1814,1915,-115,015,115,215,315,415,515,615,715,815,915,1015,1115,1215,1315,1415,1515,1615,1715,1815,1916,-116,016,116,216,316,416,516,616,716,816,916,1016,1116,1216,1316,1416,1516,1616,1716,1816,1917,-117,017,117,217,317,417,517,617,717,817,917,1017,1117,1217,1317,1417,1517,1617,1717,1817,1918,-118,018,118,218,318,418,518,618,718,818,918,1018,1118,1218,1318,1418,1518,1618,1718,1818,1919,-119,019,119,219,319,419,519,619,719,819,919,1019,1119,1219,1319,1419,1519,1619,1719,1819,1920,-120,020,120,220,320,420,520,620,720,820,920,1020,1120,1220,1320,1420,1520,1620,1720,1820,1921,-121,021,121,221,321,421,521,621,721,821,921,1021,1121,1221,1321,1421,1521,1621,1721,1821,1922,-122,022,122,222,322,422,522,622,722,822,922,1022,1122,1222,1322,1422,1522,1622,1722,1822,1923,-123,023,123,223,323,423,523,623,723,823,923,1023,1123,1223,1323,1423,1523,1623,1723,1823,1924,-124,024,124,224,324,424,524,624,724,824,924,1024,1124,1224,1324,1424,1524,1624,1724,1824,1925,-125,025,125,225,325,425,525,625,725,825,925,1025,1125,1225,1325,1425,1525,1625,1725,1825,1926,-126,026,126,226,326,426,526,626,726,826,926,1026,1126,1226,1326,1426,1526,1626,1726,1826,19BatteryDisplayNameCapacitorDisplayName10uF10MHz / 10pFCrystalDisplayNameCurrentSourceDisplayName1ADiodeFuseDisplayName1A / 10VInductorDisplayName10HLedDisplayNameMosfetDisplayName10kΩPotentiometerDisplayNamePushButtonDisplayNameResistorDisplayName1kΩ10MHz / 10pFResonatorDisplayNameSolderJumperDisplayNameSwitchDisplayNameTestPointDisplayNameTransistorDisplayNameVoltageSourceDisplayName5V \ No newline at end of file diff --git a/tests/components/normal-components/__snapshots__/board-schematic-manual-edits-schematic.snap.svg b/tests/components/normal-components/__snapshots__/board-schematic-manual-edits-schematic.snap.svg index 9522bab0b..57438cc2f 100644 --- a/tests/components/normal-components/__snapshots__/board-schematic-manual-edits-schematic.snap.svg +++ b/tests/components/normal-components/__snapshots__/board-schematic-manual-edits-schematic.snap.svg @@ -1,4 +1,4 @@ --7,-6-7,-5-7,-4-7,-3-7,-2-7,-1-7,0-7,1-7,2-7,3-7,4-7,5-7,6-6,-6-6,-5-6,-4-6,-3-6,-2-6,-1-6,0-6,1-6,2-6,3-6,4-6,5-6,6-5,-6-5,-5-5,-4-5,-3-5,-2-5,-1-5,0-5,1-5,2-5,3-5,4-5,5-5,6-4,-6-4,-5-4,-4-4,-3-4,-2-4,-1-4,0-4,1-4,2-4,3-4,4-4,5-4,6-3,-6-3,-5-3,-4-3,-3-3,-2-3,-1-3,0-3,1-3,2-3,3-3,4-3,5-3,6-2,-6-2,-5-2,-4-2,-3-2,-2-2,-1-2,0-2,1-2,2-2,3-2,4-2,5-2,6-1,-6-1,-5-1,-4-1,-3-1,-2-1,-1-1,0-1,1-1,2-1,3-1,4-1,5-1,60,-60,-50,-40,-30,-20,-10,00,10,20,30,40,50,61,-61,-51,-41,-31,-21,-11,01,11,21,31,41,51,62,-62,-52,-42,-32,-22,-12,02,12,22,32,42,52,63,-63,-53,-43,-33,-23,-13,03,13,23,33,43,53,64,-64,-54,-44,-34,-24,-14,04,14,24,34,44,54,65,-65,-55,-45,-35,-25,-15,05,15,25,35,45,55,66,-66,-56,-46,-36,-26,-16,06,16,26,36,46,56,67,-67,-57,-47,-37,-27,-17,07,17,27,37,47,57,6R110kΩC110uF \ No newline at end of file diff --git a/tests/components/normal-components/__snapshots__/capacitor-polarized-schematic.snap.svg b/tests/components/normal-components/__snapshots__/capacitor-polarized-schematic.snap.svg index be9fcf202..e602f1e25 100644 --- a/tests/components/normal-components/__snapshots__/capacitor-polarized-schematic.snap.svg +++ b/tests/components/normal-components/__snapshots__/capacitor-polarized-schematic.snap.svg @@ -1,4 +1,4 @@ -