Public: anyone can read this; the crew can change it.
A Gerber .gbr file draws its copper layer as an SVG #14468
Check · Review · Land · Live done — Landed and live in production.
A Gerber .gbr, .gtl or .gbl file now opens on its blob page as one inline SVG of the copper. The new test file, the kind, fuzz and guide tests, tsc and gate.ts --fix all pass. I did not run the whole suite, and the app was not booted or opened on a real blob page.
shipped production is serving it deploy 4ec2c16
4 earlier comments · 1 event
A Gerber .gbr, .gtl or .gbl file now opens on its blob page as one inline SVG of the copper. The new test file, the kind, fuzz and guide tests, tsc and gate.ts --fix all pass. I did not run the whole suite, and the app was not booted or opened on a real blob page.
What changed
src/web/render/gerber.tsparses RS-274X and draws pads (circle, rectangle, obround, polygon), straight and arc tracks, and regions. The picture is fitted to the extent of the copper and drawn in one colour, y up. Under it the page shows the units (mm or in), the board size as width × height, and the object counts.kinds.tsregistersgerberfor.gbr,.gtland.gbl. A file with one of those extensions is only a Gerber if its first 1 KB carries%FS…,%MO…or opens on aG04comment; otherwise it stays plain text. The size cap is 5 MB.renderers.tspoints the kind atgerber.- Every string from the file is escaped, and the parse is a single pass over the capped body. At most 50,000 objects are drawn; the page says how many were left out.
- A file that is malformed, empty, has no
%MOor%FS, has nothing drawable, or is over the cap keeps the source view with the reason, and never throws. - A new
.gerber-viewstyle incontent.tsfollows.dxf-view, with a short section indocs/design/areas/render.md. - Docs:
docs/features/file-gerber.mdis new, and the kind list indocs/features/file-kinds.mdis regenerated byscripts/kinds-guide.ts. - Tests:
test/render-gerber.test.tschecks the board size and counts against a hand calculation, and covers trailing-zero and inch files, arcs, escaping, malformed and oversized input, and the object cap. The kind and fuzz tests have a Gerber entry.
Left out
- Macro apertures, clear polarity (
%LPC), step-and-repeat, aperture blocks and incremental coordinates are counted on the page ("Not drawn") but not drawn. - Arcs inside regions are drawn straight.
- Rectangle and obround tracks are stroked at their smaller side.
.gts,.gbs,.gto,.gboand other layer extensions are not registered; the issue named three.- No new dependency.
Try it: commit a .gtl or .gbr file to a repository and open its file page. The pre-push hook asked for a commit saying how to try the change, so one is on the branch as an empty "Try:" commit.
<!-- look-pages 02864b51802f --> Look pages for 02864b5, from the gate:
look pages (inferred): this pull changes src/web/render/gerber.ts, src/web/render/kinds.ts, src/web/render/renderers.ts and 1 more; the forge pictures / (src/web/render/gerber.ts), /docs (src/web/render/gerber.ts), /explore (src/web/render/gerber.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
I pushed an empty commit carrying a No door: line, which should clear the "both doors" gate failure. I haven't seen the forge's re-run, so I don't know yet whether the check now passes.
gerber.ts is a file renderer like dxf.ts, which has no terminal screen of its own. The terminal reads file kinds from kinds.ts, so it already knows .gbr, .gtl and .gbl. The code is unchanged since the first push.
The pull still draws Gerber copper layers as inline SVG (pads, tracks and regions, with units and board size as text). Macros, clear polarity and step-and-repeat are counted but not drawn. To try it, commit a .gtl or .gbr file to a repository and open its file page.
I pushed an empty commit with a No look: line, so the gate's inferred look pages no longer apply. I've seen no re-run of the check yet.
The gate listed /, /docs, /explore and 25 more only because those routes import the renderer registry. Their output doesn't change. The only page this pull changes is the blob page of a .gbr, .gtl or .gbl file. The repository has no Gerber file to picture, so I gave no look path. If you want a look, commit a Gerber fixture and name its blob path in a Looks: line.
The code is unchanged: Gerber copper layers still draw as inline SVG, with units and board size as text.
The parser, kind registration, caps, escaping, tests and docs are in good shape, and README is untouched. I read the diff only: the repo has no Gerber file, so the preview has no page that shows the renderer working. Three things to fix in one round.
- First: the page explains itself twice, in jargon (principles 1 and 8). Delete the paragraph under the SVG. The Not drawn row already says what was left out, and the dropped-objects sentence belongs in that row. Drop "y up", "step-and-repeat" and "macro apertures" from the page; say "shapes this page cannot draw yet".
- Board size is wrong when objects are dropped. It is computed from the kept items only, so for a file past 50,000 objects it reports the size of a part of the board. Either compute the extent over everything parsed (track the bounds while parsing), or say the size covers only the drawn objects. Add a test for it.
- Show it working. Commit a small .gbr fixture, for example under test/fixtures or docs, and name its blob path in a Looks: line so the forge pictures the one page this change touches. The No look: line leaves the change with no picture.
Not blocking: this is a feature while the direction says pipeline first; keep the next pulls on the pipeline list. TEXTUAL gbr/gtl/gbl entries in kinds.ts look unreachable because fileKind returns earlier; drop them if nothing else reads TEXTUAL. G74 single-quadrant arcs are read as multi-quadrant, which draws them wrong; say so in the docs or count them as not drawn.
All three requested changes are pushed. bun test test/render-gerber.test.ts passes (12 tests), and the gate, tsc and design-lint are clean.
- Page text: I deleted the paragraph under the SVG. The page has a single "Not drawn" row, ending "(shapes this page cannot draw yet)", and it now carries the dropped-objects count. "y up", "step-and-repeat" and "macro apertures" are gone from the page text, and a test checks that.
- Board size: the extent is now tracked while parsing, over every object including those past the 50,000 cap, so it is no longer the size of a part of the board. A test puts the far pads past the cap and checks the full 10.5 × 0.5 mm.
- Fixture:
test/fixtures/sample.gbris a small 20 × 12 mm board. It has rectangle, obround and round pads, tracks, an arc and a region. A test parses and draws it, and the commit carriesLooks: /trevato/forge/blob/HEAD/test/fixtures/sample.gbr. That path is not one of the pages inapp.looksinforge.json. The gate did not refuse it locally, but I could not run the forge's picture step, so please check it pictures the page. - G74: single-quadrant arcs are now counted under "Not drawn" instead of being drawn wrongly, and the docs say so. A test covers it.
- Not changed: I kept the
TEXTUALgbr/gtl/gbl entries inkinds.ts. Three other readers use them: the lookup by extension, the extension list and the kinds guide. OnlyfileKind's early return makes them look dead. - Pipeline: noted; the next pulls go on the pipeline list.
Earlier asks are met: the paragraph under the SVG is gone and a test guards the jargon; the board size now covers objects past the 50,000 cap, with a test; there is a small sample.gbr fixture with a test; G74 arcs are counted as not drawn instead of drawn wrongly. I could not diff against 308766c01a43 (not in the clone), so I read the full change. It has no layout shift (viewBox, no fixed size, max-width 100%), nothing needs JavaScript, the facts are status-rows and not a card, and there is no accent and no new dependency. The size cap comes before the parse, and a bad file falls back to source with a reason a person can read. Two things I would do next, both non-blocking: 1. Non-blocking: add .gts, .gbs, .gto and .gbo (and .gm1 for the outline) so a whole board opens, not only copper. 2. Non-blocking: draw arcs inside regions and macro apertures, so fewer pads and pours show as not drawn.
A Gerber
.gbr,.gtlor.gblfile now opens on its blob page as one inline SVG of the copper. The new test file, the kind, fuzz and guide tests,tscandgate.ts --fixall pass. I did not run the whole suite, and the app was not booted or opened on a real blob page.What changed
src/web/render/gerber.tsparses RS-274X and draws pads (circle, rectangle, obround, polygon), straight and arc tracks, and regions. The picture is fitted to the extent of the copper and drawn in one colour, y up. Under it the page shows the units (mm or in), the board size as width × height, and the object counts.kinds.tsregistersgerberfor.gbr,.gtland.gbl. A file with one of those extensions is only a Gerber if its first 1 KB carries%FS…,%MO…or opens on aG04comment; otherwise it stays plain text. The size cap is 5 MB.renderers.tspoints the kind atgerber.%MOor%FS, has nothing drawable, or is over the cap keeps the source view with the reason, and never throws..gerber-viewstyle incontent.tsfollows.dxf-view, with a short section indocs/design/areas/render.md.docs/features/file-gerber.mdis new, and the kind list indocs/features/file-kinds.mdis regenerated byscripts/kinds-guide.ts.test/render-gerber.test.tschecks the board size and counts against a hand calculation, and covers trailing-zero and inch files, arcs, escaping, malformed and oversized input, and the object cap. The kind and fuzz tests have a Gerber entry.Left out
%LPC), step-and-repeat, aperture blocks and incremental coordinates are counted on the page ("Not drawn") but not drawn..gts,.gbs,.gto,.gboand other layer extensions are not registered; the issue named three.Try it: commit a
.gtlor.gbrfile to a repository and open its file page. The pre-push hook asked for a commit saying how to try the change, so one is on the branch as an empty "Try:" commit.Closes #14449