Skip to content

fix: silently ignore Gerber X2 attribute commands (TF, TA, TO, TD)#282

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/gerber-x2-attributes
Feb 27, 2026
Merged

fix: silently ignore Gerber X2 attribute commands (TF, TA, TO, TD)#282
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/gerber-x2-attributes

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

Summary

KiCad >= 8 and other modern EDA tools generate Gerber X2 files containing %TF%, %TA%, %TO%, and %TD% attribute commands. These are standard Gerber X2 metadata extensions (defined by Ucamco in 2014) that don't affect rendering — gerbv already renders these files correctly — but parse_rs274x() doesn't recognize them, causing error-level spam:

Unknown RS-274X extension found %TF% at line 3 in file "..."

This PR adds four case statements to match these commands and log them at GERBV_MESSAGE_NOTE level instead of GERBV_MESSAGE_ERROR. The existing cleanup code (lines 1853-1858) already reads until the trailing * character, so the attribute data is consumed automatically — only the case/break is needed.

Gerber X2 Attribute Commands

Command Name Purpose
%TF.<name>,<values>*% File Attribute Metadata about the file (software version, creation date, etc.)
%TA.<name>,<values>*% Aperture Attribute Metadata attached to aperture definitions
%TO.<name>,<values>*% Object Attribute Metadata attached to graphical objects
%TD[.<name>]*% Delete Attribute Removes a previously set attribute

Changes

  • src/gerber.c: Add case A2I('T','F') / A2I('T','A') / A2I('T','O') / A2I('T','D') to the switch in parse_rs274x(), logging at NOTE level and breaking
  • test/inputs/test-gerber-x2-attributes.gbx: Minimal Gerber X2 test file with all four attribute types
  • test/golden/test-gerber-x2-attributes.png: Golden reference for the test
  • test/tests.list: Register the new test

Fixes #249

Test plan

  • Build gerbv from modified source (cmake .. && make)
  • Load test Gerber X2 file — no error messages, only NOTE-level log
  • Run test suite (./run_tests.sh) — new test passes, no regressions

KiCad >= 8 and other modern EDA tools generate Gerber X2 files with
%TF%, %TA%, %TO%, and %TD% attribute commands. These are standard
metadata extensions defined by Ucamco in 2014 that don't affect
rendering. gerbv already renders these files correctly, but the
RS-274X parser didn't recognize the commands, causing error-level
spam in the Messages pane.

Add four case statements in parse_rs274x() to match these commands
and log them at NOTE level instead of ERROR. The existing cleanup
code already reads until the trailing '*', so the attribute data is
consumed automatically.

Fixes gerbv#249
@spe-ciellt spe-ciellt self-assigned this Feb 27, 2026
@spe-ciellt
Copy link
Copy Markdown
Contributor

Thank you for this patch. You've been busy it seems like. ;) I will work through your list of PRs. If they are good enough I apply them else I will leave comments.

@spe-ciellt
Copy link
Copy Markdown
Contributor

Tested on the branch. Build is clean, all four attribute types (TF, TA, TO, TD) are handled correctly.

Code: The fix slots cleanly into the existing switch pattern. The unconditional cleanup code after the switch (gerb_ungetc + read-until-* loop) consumes the attribute content automatically, so only the case/break is needed — no extra parsing. The %TD*% edge case (no attribute name, * immediately follows) also works correctly. Message format and gerbv_escape_char usage are consistent with the rest of the function.

Tests: New test test-gerber-x2-attributes passes. 91/101 pass overall; the 10 failures are the same Cairo-version mismatches as the develop baseline — no regressions.

The NOTE vs ERROR distinction is only visible in the GUI Messages pane, not CLI output, so it can't be exercised by the automated suite — but the rendered output test is the right check here.

@spe-ciellt spe-ciellt merged commit f08428c into gerbv:develop Feb 27, 2026
1 check passed
@rampageservices rampageservices deleted the fix/gerber-x2-attributes branch February 27, 2026 17:20
@spe-ciellt spe-ciellt added the fix Solution for a potential problem or omission. label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Solution for a potential problem or omission.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown RS-274X extension found

2 participants