feat(barcode): ^B4 Code 49 (stacked 1D)#91
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements support for the Code 49 barcode (^B4 ZPL command), including parsing, generation, and rendering logic. The implementation covers height clamping to meet bwip-js requirements, UI property controls, and localization across all supported languages. Feedback suggests refining the display size calculation in bwipHelpers.ts by using the calculated rendering scale instead of a constant for better accuracy on high-DPI displays.
Adds the ^B4 Code 49 stacked-1D symbology — registry leaf with
custom `mode` prop ('A' | '0'..'5'), parser handler, bwip-js mapping,
getDisplaySize case, command-support flag, 32 locale entries.
bwip-js `mode` accepts numbers 0-5 only; ZPL m='A' (auto) is
expressed by omitting the option so bwip's internal auto-subset
picker runs, matching firmware behaviour. Garbage values in `mode`
(parser-rejected on entry, possible via hand-edited JSON) fall back
to auto-mode rather than throwing.
bwip-js rejects code49 `rowheight` outside 8..50 modules, so the
valid ZPL h range is [8·moduleWidth, 50·moduleWidth] dots. Enforced
at four layers, each catching a distinct caller:
- UI: NumberInput min/max blocks invalid typing (dynamic on
moduleWidth)
- normalize: moduleWidth change re-clamps height across fields
(guards non-finite / non-positive moduleWidth so
programmatic paths don't anchor on garbage)
- commit: Konva transformer drag past the range pins height to
the limit before it lands in props
- render: bwipHelpers clamps as a defensive net for hand-edited
JSON loads
Without the cross-layer enforcement, canvas silently falls back to a
valid rowheight while props (and emitted ZPL) carry the invalid
value, producing design-vs-print drift on resize or moduleWidth
change.
Labelary caveat: Labelary's docs list ^B4 as supported, but the
emulator renders the HRI text only and omits the bars (verified
May 2026, same situation as ^BB CODABLOCK F). bwip-js is the
authoritative render; no visualRegression / labelarySync fixtures.
Tests: 10 added — 3 round-trip (parser/generator/mode handling),
7 clamp-contract (normalize × 5, commit × 2).
d6b4d5b to
29654b3
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.
No description provided.