Skip to content

fix(zpl): reverse text uses ^GB+^FR knockout pattern instead of ^LR#95

Merged
u8array merged 1 commit into
mainfrom
fix/reverse-text-gb-fr
May 24, 2026
Merged

fix(zpl): reverse text uses ^GB+^FR knockout pattern instead of ^LR#95
u8array merged 1 commit into
mainfrom
fix/reverse-text-gb-fr

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 updates the implementation of reverse (white-on-black) text to use a per-field approach involving a filled black box (^GB) and the field reverse flag (^FR), replacing the legacy global label reverse. The ZPL parser is updated with logic to stash pending backgrounds and collapse them with subsequent text fields to ensure round-trip consistency. Additionally, the canvas preview was adjusted to match the printer's font height exactly. Review feedback suggests improving the parser's robustness by flushing the background stash in the GF and ^XA handlers, preserving metadata by merging comments during object collapse, and addressing a dimension mismatch when using block text with the new reverse-text pattern.

Comment thread src/lib/zplParser.ts
Comment thread src/lib/zplParser.ts
Comment thread src/lib/zplParser.ts
Comment thread src/registry/text.tsx Outdated
^LRY/^LRN wraps a single field with label-reverse, which Zebra
firmware (and Labelary) treat as a global bitmap flip rather than
per-field inversion. The result: our reverse-text emit produced no
visible inversion on print, only the canvas faked the effect.

Switch the text emitter to the standard ZPL pattern for white-on-
black: a filled black ^GB at the field anchor (sized to the rendered
ink bbox) followed by ^FR^FD so the printer knocks the glyphs out of
the black.

Parser stashes filled-black ^GB candidates and collapses them with a
following ^FR text at the same anchor with matching bbox back into a
single reverse-text object, so the round-trip stays one-to-one. Hand-
written ZPL with unrelated ^GB+^FR pairs at mismatched anchors or
sizes round-trips unchanged via the existing box path.

Scope limited to text per the open follow-up ticket; box / ellipse /
line still emit ^LR via wrapReverse and remain broken on Labelary
(rarely used; addressed separately).
@u8array u8array force-pushed the fix/reverse-text-gb-fr branch from ad9a314 to 687fd77 Compare May 24, 2026 21:08
@u8array u8array merged commit d3fd583 into main May 24, 2026
2 checks passed
@u8array u8array deleted the fix/reverse-text-gb-fr branch May 24, 2026 21:09
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