Skip to content

fix(code128): translate ZPL >X escape sequences for canvas render#44

Merged
u8array merged 2 commits into
mainfrom
fix/code128-zpl-escapes
May 10, 2026
Merged

fix(code128): translate ZPL >X escape sequences for canvas render#44
u8array merged 2 commits into
mainfrom
fix/code128-zpl-escapes

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 10, 2026

No description provided.

Without translation, '>5' was encoded as two literal Subset-B symbols, so
content like 'STRSTR>52316094000242201' rendered ~21 symbols on canvas
while Zebra firmware reads '>5' as FNC1, switches to Code C for the
trailing digit run and prints ~15 symbols. Result: canvas bbox markedly
wider than the printed barcode.

parseZplCode128Escapes converts >0/>5-8/>9 to bwip-js parsefnc syntax
and drops >: />; subset switches (bwip auto-mode picks the subset).
Plain ASCII content stays on the existing toCode128BRaw raw path.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces ZPL Code 128 escape sequence translation to ensure correct barcode rendering when using bwip-js. It adds the parseZplCode128Escapes utility and integrates it into buildBwipOptions. Feedback focused on correctly handling the >9 escape sequence, which should only insert an FNC1 character when positioned at the start of the string, and suggested corresponding updates to documentation, implementation, and test coverage.

Comment thread src/components/Canvas/bwipHelpers.ts Outdated
Comment thread src/components/Canvas/bwipHelpers.ts Outdated
Comment thread src/components/Canvas/bwipHelpers.test.ts Outdated
Per ZPL II manual, the >9 invocation char inserts FNC1 only when it is
the first character of the field data. Mid-string >9 is just a Subset C
invocation, which bwip-js auto-mode handles for digit runs without an
explicit FNC1.

Reviewer-spotted (gemini-code-assist on PR #44).
@u8array
Copy link
Copy Markdown
Owner Author

u8array commented May 10, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for ZPL Code 128 escape sequences by adding the parseZplCode128Escapes utility and updating buildBwipOptions to utilize bwip-js's parsefnc mode when these sequences are detected. This ensures accurate barcode rendering that matches Zebra firmware behavior, particularly for FNC1 and subset switching. Comprehensive tests have been added to verify the new logic. I have no feedback to provide.

@u8array u8array merged commit c43145e into main May 10, 2026
2 checks passed
@u8array u8array deleted the fix/code128-zpl-escapes branch May 10, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant