Skip to content

feat(barcode): ^B4 Code 49 (stacked 1D)#91

Merged
u8array merged 1 commit into
mainfrom
feat/zpl-b4-code49
May 24, 2026
Merged

feat(barcode): ^B4 Code 49 (stacked 1D)#91
u8array merged 1 commit into
mainfrom
feat/zpl-b4-code49

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 24, 2026

No description provided.

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 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.

Comment thread src/components/Canvas/bwipHelpers.ts Outdated
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).
@u8array u8array force-pushed the feat/zpl-b4-code49 branch from d6b4d5b to 29654b3 Compare May 24, 2026 08:50
@u8array u8array merged commit f41ad42 into main May 24, 2026
2 checks passed
@u8array u8array deleted the feat/zpl-b4-code49 branch May 24, 2026 11:03
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