fix(zpl): reverse text uses ^GB+^FR knockout pattern instead of ^LR#95
Conversation
There was a problem hiding this comment.
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.
^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).
ad9a314 to
687fd77
Compare
No description provided.