python-barcode icon indicating copy to clipboard operation
python-barcode copied to clipboard

Text placement in ImageWriter

Open tytouf opened this issue 2 years ago • 2 comments

I believe text is incorrectly located in barcode when using ImageWriter as of 0.14.0. This is mainly due to a wrong computation of text height which is a very common problem due to the fact that total height for a font is different from the height of rendered glyphs for most of the ascii characters.

Attached is a proposed patch to place text correctly. Note that because most of the time a barcode is followed by a text with capital letters, the blank space at the bottom is more that 1mm (which would be nice to set as an option). It should be closer to 1mm when using letters that goes below the font baseline ('p', 'q', etc).

text_placement.patch.txt

tytouf avatar Oct 05 '22 22:10 tytouf

There have been changes to how text is aligned and how it's size is calculated since 0.14. Do you still have the same issue on main?

See https://github.com/WhyNotHugo/python-barcode/pull/165 for discussion on this.

WhyNotHugo avatar Oct 12 '22 13:10 WhyNotHugo

I didn't test with the source but it should be equivalent.

tytouf avatar Oct 12 '22 13:10 tytouf