Skip to content

Conversation

@dekoza
Copy link

@dekoza dekoza commented Jan 3, 2026

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:

  • Added support for EAN-2 and EAN-5 addons. These supplemental barcodes can be added to EAN-13, EAN-8, ISBN-13, ISBN-10, and ISSN barcodes via the addon parameter. EAN-2 is commonly used for periodical issue numbers, EAN-5 for book prices.
  • Added support for EAN-2 and EAN-5 addons to UPC-A barcodes via the addon parameter, following the same interface as EAN-13.
  • Addon rendering includes a 9-module quiet zone separator between the main barcode and the addon, as required by the GS1 specification. This ensures proper scanning of barcodes with addons.
  • Added scannability tests for EAN-2 and EAN-5 addons using the pyzbar library.
  • Adjusted rendering of EAN barcodes when using guardbar=True together with an EAN-2/EAN-5 addon: the addon label is placed above the addon bars per GS1 layout, rather than being mixed into the main text line.
  • Fixed ISSN to accept full EAN-13 format (13 digits starting with 977) and preserve digits 11-12 (sequence variant) instead of always replacing them with "00".

Copilot AI review requested due to automatic review settings January 3, 2026 19:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 addon parameter
  • 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.

dekoza and others added 3 commits January 3, 2026 20:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +285 to +289
# Track addon bar positions
if not in_addon:
addon_start_x = xpos
in_addon = True
addon_end_x = xpos + self.module_width * abs(mod)
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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)

Copilot uses AI. Check for mistakes.
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