WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
558 stars 123 forks source link

how to set text position? #44

Open goog opened 5 years ago

goog commented 5 years ago

code128_barcode

blutme commented 4 years ago

You can configure several parameters, including changing the distance between the text and the barcode (.text_distance':1 option)...

for example:

def barcode_generator(x): <indentation> ean = barcode.get('ean13', x, writer=ImageWriter()) <indentation> filename = ean.save(x, options = {'text_distance':1, 'quiet_zone':2.5, module_height':6,'font_size':16})

x="770332600000" barcode_generator(x):

WhyNotHugo commented 4 years ago

Keeping this open as a reminder to improve the docs on this topic.

toxicantidote commented 2 years ago

As a side note, the _textdistance option is the distance from the top of the barcode to the top of the text. I would have expected this to be the distance from the bottom of the barcode to the text instead, as it seems unlikely that the user would want the text and barcode to overlap.

tytouf commented 1 year ago

While using python-barcode I found that the text placement is incorrect. I believe text_distance is used correctly as the distance between the bottom of the barcode modules and the text but the text is drawn at the wrong place which means that for small text_distance values, the text overlaps on the barcode.

tytouf commented 1 year ago

I opened #177 and proposed a patch that fixes the issue when using small values of text_distance.