Conversation
…they are allowed by ISSN spec (see issn.org).
…dering. Fix addon rendering by adding quiet zone.
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive support for EAN-2 and EAN-5 supplemental barcodes (addons) to the library, addressing issue #140. The implementation enables barcodes to include additional encoded data commonly used for periodical issue numbers (EAN-2) and retail prices (EAN-5).
Key changes:
- Added EAN-2 and EAN-5 addon support to EAN-13, EAN-8, UPC-A, ISBN-13, ISBN-10, and ISSN barcodes via an
addonparameter - Implemented proper GS1-compliant addon rendering with 9-module quiet zone separator
- Fixed ISSN barcode to accept full EAN-13 format and preserve sequence variant digits (positions 11-12)
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| barcode/charsets/addons.py | New file defining addon encoding patterns (EAN-2/EAN-5 parity patterns, guard patterns, digit encoding) |
| barcode/charsets/ean.py | Imports and re-exports addon constants for EAN barcode compatibility |
| barcode/charsets/upc.py | Imports and re-exports addon constants for UPC barcode compatibility |
| barcode/ean.py | Implements addon support in EAN-13 and EAN-8 classes with validation and pattern building methods |
| barcode/upc.py | Implements addon support in UPC-A class following same interface as EAN |
| barcode/isxn.py | Adds addon support to ISBN-13, ISBN-10, and ISSN; fixes ISSN to handle full EAN-13 format with preserved sequence digits |
| tests/test_addon.py | Comprehensive test suite for addon functionality covering EAN, UPC, and ISXN barcodes |
| tests/test_checksums.py | Tests for ISSN checksum calculation in both short and full EAN-13 forms |
| tests/test_scannability.py | New integration tests using pyzbar to verify generated barcodes are scannable |
| docs/getting-started.rst | Documentation and examples for using EAN-2/EAN-5 addons |
| docs/changelog.rst | Changelog entries describing the new addon features |
| tox.ini | Added pyzbar and cairosvg dependencies for scannability tests |
| .github/workflows/tests.yml | Added system dependency installation for zbar and cairo libraries |
| .gitignore | Added .coverage file to gitignore |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Track addon bar positions | ||
| if not in_addon: | ||
| addon_start_x = xpos | ||
| in_addon = True | ||
| addon_end_x = xpos + self.module_width * abs(mod) |
There was a problem hiding this comment.
The addon bar position tracking logic should only track foreground bars, not background spaces. Currently, when height_factor == -1.0 (addon bars), the code updates addon_end_x regardless of whether it's a foreground bar (mod > 0) or background space (mod < 1). This could cause the addon text to be positioned incorrectly, centered over a point that includes background spaces beyond the last actual bar. The check if height_factor == -1.0: should be combined with if mod > 0: or moved inside the else block at line 295.
| # Track addon bar positions | |
| if not in_addon: | |
| addon_start_x = xpos | |
| in_addon = True | |
| addon_end_x = xpos + self.module_width * abs(mod) | |
| # Track addon bar positions only for foreground bars | |
| if mod > 0: | |
| if not in_addon: | |
| addon_start_x = xpos | |
| in_addon = True | |
| addon_end_x = xpos + self.module_width * abs(mod) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…g without guardlines.
I was searching for a way to generate EAN barcodes with EAN-2 and EAN-5 addons. This library seems to be the default for all barcode-related generation but it lacked this crucial feature that I need, so I decided to add it.
Changes made:
addonparameter. EAN-2 is commonly used for periodical issue numbers, EAN-5 for book prices.addonparameter, following the same interface as EAN-13.pyzbarlibrary.guardbar=Truetogether with an EAN-2/EAN-5addon: the addon label is placed above the addon bars per GS1 layout, rather than being mixed into the main text line.