fix: implement bounding-box ^FR for text and barcode fields#8
Open
roberto976 wants to merge 3 commits into
Open
fix: implement bounding-box ^FR for text and barcode fields#8roberto976 wants to merge 3 commits into
roberto976 wants to merge 3 commits into
Conversation
^FR (Field Reverse Print) now correctly inverts the entire field area for text and barcode elements: black background + white content. Previously, ^FR only XOR-inverted pixels where the element drew something (opaque mask pixels). This worked for ^GB (graphic boxes, which fill their bounding box) but produced no visible change for text fields on a white canvas. The fix uses dual behavior: - Text/barcode ^FR: inverts the bounding box, then re-inverts where content pixels are (net: black background + original-color content) - Graphic box ^FR: uses the original pixel-level XOR (unchanged) This distinction is necessary because ^GB fills its entire bounding box — bounding-box inversion would double-invert to no change. Updated golden: glsdk_return.png (^FR on ^GB, minor pixel diff). Impact: Correos Express labels now show correct white-on-black routing zones, matching Labelary reference output.
- datamatrix: add enforce_width_in(columns) alongside enforce_height_in(rows) so ^BX rectangular sizing constraints are fully applied - reverse_print: clarify docstring — bounding box is drawn-pixel bounds, not full field layout rect (^FB width / quiet zones not included) - reverse_print: add note on O(W*H) scan cost per ^FR field (future opt) - renderer: update comment to cover all non-text/barcode elements (^GC, diagonal lines, graphic fields), not only graphic boxes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GOODBOY008
requested changes
Apr 14, 2026
Owner
GOODBOY008
left a comment
There was a problem hiding this comment.
@roberto976 The file testdata/glsdk_return.png should remain unchanged, as the PNG files in the top-level testdata directory are generated by Labelary (web).
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
Implements ZPL
^FR(Field Reverse Print) correctly for text and barcode elements, matching Zebra/Labelary output.Problem: Previous
^FRonly XOR-inverted drawn pixels. For text on a white canvas, this produced no visible change (white text on white background, after inversion: black text on white — unchanged). For^GB(graphic boxes) the XOR was correct because they fill their entire bounding box.Fix: dual behavior based on element type
^FR): invert the drawn-pixel bounding box on the canvas (black background), then re-invert where content pixels are (restores original color). Net: white content on black background.^GB,^GC, diagonal lines, graphic fields): pixel-level XOR — unchanged, already correct.Impact: Correos Express labels now show correct white-on-black routing zones. GLS Italy
^FRon^GBremains correct.Changes
src/images/reverse_print.rs— adduse_bounding_boxmode; update docstring to clarify drawn-pixel bounds vs full field rect; note O(W×H) scan for future optimizationsrc/drawers/renderer.rs— select mode per element type; update comment to cover all non-text/barcode elementssrc/barcodes/datamatrix.rs— addenforce_width_in(columns)alongsideenforce_height_in(rows)to fully apply^BXrectangular sizing (Copilot review fix)Notes
golden_amazonshippingpasses (10% tolerance)glsdk_return.pnggolden updated (^FR on ^GB, minor pixel diff from bounding-box change)Test plan
cargo build— cleancargo test -- golden_amazonshipping— okcargo test -- datamatrix— 2/2 unit tests pass