Repository navigation
feat(code128): the mode prop emits ^BC m=A and the canvas packs digit runs into Subset C - #588
Merged
Merged
Conversation
Owner
|
Thanks for the PR! Since #593 landed, the canvas's existing ^FD reader should handle mode A as well, while mode derivation and capability handling should move into core. I'll take it from here. |
… runs into Subset C Code 128 had no way to pick the ^BC m parameter, so every export was mode N (Subset B, one symbol per digit) and import dropped an m=A. A numeric payload prints much wider than it needs to: 0240018268623 at ^BY2 is 356 dots in mode N and 246 dots in mode A. - `mode` (N | A) on the 1D props, honoured by Code 128 only; gs1 (m=D) wins - emit `^BC…,A`, parse m=A back into `mode: 'A'` - canvas renders mode A from an automatic subset plan (ISO/IEC 15417 Annex E, Subsets B/C) so the preview width matches the print - panel checkbox (hidden while GS1 is on), MCP prop doc, label in every locale Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h its bound chips, and an unmodeled m is reported
u8array
force-pushed
the
feat/code128-auto-mode
branch
from
October 31, 2026 12:33
78605a8 to
5c83712
Compare
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.
Summary
Code 128 had no way to set the
^BCm parameter. Every export was mode N (Subset B, one symbol per character), and an imported^BC…,Asilently lost itsA: the parser kept the field, the preview rendered it at Subset B width, and the next export wrote it back as mode N.For numeric payloads that costs a lot of label width.
0240018268623at^BY2:Changes:
Barcode1DPropsgains an optionalmode('N' | 'A',CODE128_MODES), honoured by Code 128 only.gs1(m=D) still wins, so a GS1-128 field never emitsA.^BCo,h,f,g,e,Awhenmode === 'A'; the default stays the bare command, so existing designs export byte-identically.^BC…,Aparses intomode: 'A'(newbcAutofield flag, reset alongsidebcGs1).planCode128AutoSymbols(incode128Subset.ts) plans mode A per ISO/IEC 15417 Annex E over Subsets B/C (start in C on a leading run of 4+ digits or a 2-digit payload; mid-payload runs of 4+ switch to C, an odd run leaves its first digit in B; drop back to B for a trailing single digit).buildBwipOptionsrenders that plan as bwip raw, so the preview width equals the printed width. Payloads with control bytes returnnulland keep the existing A/B invocation path.ca).code128props doc listsmode.Note: Annex E is the reference here, not firmware measurements. When a run has an odd digit count, Zebra's auto mode may leave a different digit outside Subset C. Symbol count and width are the same either way, and so is the decoded data, but bar-for-bar parity with a real ZD-series print is unverified. I don't have a Zebra handy to measure; happy to adjust if you see a difference.
Test plan
pnpm exec vitest run: 374 files / 6138 tests pass. Newpackages/core/src/lib/code128Auto.test.tscovers the planner (even/odd leading runs, short runs stay in B, 2-digit payload, mid-payload switches, control-byte fallback), emit with and withoutA, GS1 winning overA, import of^BC…,Avs bare^BC, and the rendered footprint (246 vs 356 dots)tsc -bandeslinton the changed files clean🤖 Generated with Claude Code