fix: draw the sot23 body outline and pin 1 marker (#732) - #733
Open
DPS0340 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #732.
sot23(3-pin) was the only SOT in the library with zero silkscreen paths — no body outline, no pin 1 marker.sot23_5, in the same file and same function, already had both.What this draws
Ported from KiCad's
SOT-23-3, whose pads are byte-identical to the ones footprinter already generates, so only the silkscreen needed adding.The body can't be a closed rectangle: the pads overhang it horizontally (pad 1 spans
x[-1.80, -0.475], the body edge is atx = -0.91), so this emits 7 open segments — full-width top and bottom runs, a left edge broken twice by pins 1/2, and a right edge broken by pin 3 — plus the pin 1 chevron. 8 paths total, matching KiCad's 8.Clearances are derived, not hardcoded:
padClearance = strokeWidth / 2 + 0.2, which reproduces KiCad's uniform 0.26 mm and follows the pads ifpw/pchange, so custom strings likesot23_w3_h1.5_p0.95mmstay correct.Verification
Geometric, not just visual. Added
sot23_3 silkscreen keeps clear of every pad, which densely samples each segment, subtracts the stroke half-width, and asserts ≥ 0.2 mm to every pad:I ran the same check against KiCad's own
SOT-23-3first to confirm the checker agrees with the reference (it reports no overlap there), then used it to catch two bad iterations of my own: my first attempt drew a closed rectangle straight through all three pads, and my second stopped exactly at the pad edges with 0 clearance. Both were rejected before I looked at any SVG.Both new tests bite. Reverting only
src/fn/sot23.tsand re-running:The clearance test also asserts
silkscreenPaths.length > 0so it can't pass vacuously if the silkscreen ever disappears again — which is exactly how this bug survived.Suite:
469 pass / 0 fail,biome formatclean,bun run build(ESM + DTS) ok. 4 snapshots updated plus the parity snapshot; I rendered the parity snapshot and compared it side by side against the KiCad reference — the outlines now match, andcourtyardDiffPercentstays0.00%.Note on the parity test
tests/kicad-parity/sot23_kicad_parity.test.tsreported Diff: 0.00% the whole time the silkscreen was missing, because it compares copper via boolean difference and courtyard area only. The fixture already returnsfpSilkscreenElementsbut no parity test in the repo consumes it. If you'd like, I can open a follow-up that asserts silkscreen presence across the parity suite — I'd expect it to find more cases like this one.