Skip to content

Feature request: add option to control light margin indicator (>) in EAN-13 barcodes #242

@RobKuipers

Description

@RobKuipers

Add option to control light margin indicator (>) in EAN-13 barcodes

Problem Description

Currently, when generating EAN-13 barcodes with human-readable text enabled, python-barcode automatically adds a light margin indicator (>) character at the end of the barcode text. This is a valid standard practice, but there are use cases where users would want control over this feature.

Current Behavior

  • EAN-13 barcodes with text display include the > character as a light margin indicator
  • There's no option to remove this indicator while keeping other human-readable text
  • The only workaround is to use write_text=False and implement text separately

Expected Behavior

Provide an option to control the display of the light margin indicator independently from other human-readable text.

Proposed Solution

Add a new option called show_light_margin_indicator (or similar) that allows users to control this feature:

options = {
    'write_text': True,
    'show_light_margin_indicator': False  # New option
}

This option would default to True to maintain backward compatibility.

Use Cases

  1. Custom barcode designs where the light margin indicator conflicts with layout
  2. Integration with existing systems that handle quiet zones differently
  3. Creating minimal/clean barcode displays
  4. Maintaining consistent styling across different barcode types

Implementation Suggestions

The light margin indicator is likely added in the text rendering section of the EAN-13 implementation. The option would need to:

  1. Be added to the available options for EAN-13 barcodes
  2. Control whether the > character is appended to the human-readable text
  3. Be documented in the options section

Additional Context

The light margin indicator (>) serves as a visual reminder of the required quiet zone on the right side of the barcode. While it's a useful standard feature, providing an option to control its display would give users more flexibility without removing it entirely for backward compatibility.

Example Code

import barcode
from barcode.writer import ImageWriter

# Create barcode with light margin indicator (current default)
ean = barcode.get('ean13', '123456789012', writer=ImageWriter())
filename = ean.save('with_indicator', options={'write_text': True})

# Create barcode without light margin indicator (proposed)
options = {
    'write_text': True,
    'show_light_margin_indicator': False
}
ean = barcode.get('ean13', '123456789012', writer=ImageWriter())
filename = ean.save('without_indicator', options=options)

Backward Compatibility

This feature would be completely backward compatible as the default value would maintain current behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions