Repository navigation
Draw Code 128, EAN, Code 39 and ITF-14 barcodes as vectors - #104
Merged
Merged
Conversation
barcode encodes Code 128 (sets A, B and C chosen as the text goes), EAN-13, EAN-8, Code 39 and ITF-14, adds a missing check digit and checks a given one, and draws the bars as one path and one fill. width counts the quiet zones, module_size sets the narrowest bar, and text: true writes the encoded text under the bars. Gamba's own API takes barcode as a box. Assisted-by: Claude [Claude Code]
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.
Labels carry a Code 128, products an EAN and cartons an ITF-14, but drawing one took another gem plus glue code, and a bitmap scans worse once scaled. This is the second part of #74, after QR codes in #103; DataMatrix comes last.
barcodeencodes the data and draws its bars as one path and one fill, in pure Ruby.widthcounts the standard quiet zones, ormodule_sizesets the narrowest bar;heightis the bars' height.text: truewrites the encoded text under the bars, attext_size.at, orpositionandvposition, withcolorandquiet_zone: false. In Gamba's own API,barcodeis a box withalign.Proof
test/barcode_test.rbreads every type back with zbar from the page rendered at 150 dpi: fixed contents (all three Code 128 sets, control characters, check digits left out or given) and random ones on a seed, 36 symbols in all. Bar positions and the single fill are checked in the content stream, and the text's glyphs, size and the cursor below them with mutool. An A4 sheet of 24 labels, each with a QR code and an ITF-14, weighs 25.7 KB and renders in 183 ms without JIT. Encoding a 23-character Code 128 takes 0.03 ms.rake test: 1363 runs, 0 failures; RuboCop is clean.Generated by Claude Code