fix(code128): translate ZPL >X escape sequences for canvas render#44
Conversation
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.
There was a problem hiding this comment.
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.
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).
|
/gemini review |
There was a problem hiding this comment.
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.
No description provided.