Repository navigation
Fix EAN/UPC HTML barcode rendering with showCode - #217
Open
siarheipashkevich wants to merge 1 commit into
Open
siarheipashkevich wants to merge 1 commit into
siarheipashkevich wants to merge 1 commit into
Conversation
The HTML renderer never learned about the retail UPC-A/EAN layout: it still subtracted showCode + 12 from every bar while digit bars already use 7/11 of the requested height. As a result the bars were chopped to a few pixels (7/11 * 55 - 26 = 9px for showCode 14 at h=55) and the human-readable digits were drawn as one centered string overlapping the taller guard bars. Skip the subtraction for the eanupc layout, mirroring SVG/PNG, and render the split HRI digits positioned the same way as buildEanUpcHriSvg does. Non-EAN symbologies keep the previous behaviour; a boolean showCode now falls back to the 12px font size SVG uses instead of blowing up to 1px.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
getBarcodeHTML()never learned about the retail UPC-A/EAN layout (commit ca3e928, "Add QR logo overlay and retail UPC-A/EAN layout"). Digit bars already use 7/11 of$h, but the HTML renderer still subtractsshowCode + 12from every bar, so bars get shortened twice and the digits are drawn as a single centered string.Example:
getBarcodeHTML('5901234123457', 'EAN13', 2, 55, 'black', 14)7/11 * 55 - (14 + 12) = 9px35px55 - 26 = 29px55px5 901234 123457The PNG and SVG renderers already handle this through
usesEanUpcLayout()(if ($showCode && !$eanLayout)), the HTML renderer was left behind. A rendered comparison is attached in the issue/PR discussion if useful.Fix
getBarcodeHTML()skips theshowCode + 12subtraction for theeanupclayout and reserves the same quiet-zone label margins SVG/PNG use;buildEanUpcHriHtml()mirrorsbuildEanUpcHriSvg(): first/last digit beside the bars, middle digits centered under the left/right data zones for EAN-8, EAN-13, UPC-A and UPC-E;fontSize + 12, full code centered at the bottom);showCode = truenow falls back to the 12px font SVG uses instead of rendering 1px digits. The parameter is documented as an int font size, but passing the SVG default (true) silently produced unreadable output.Tests
Added HTML coverage next to the existing SVG/PNG retail-layout tests in
tests/UpcALayoutAndQrLogoTest.php:testEan13HtmlRetailLayoutKeepsFullHeightAndSplitHritestEan13HtmlWithoutShowCodeHasNoDigitstestEan13HtmlShowCodeTrueUsesSvgDefaultFontSizetestNonEanHtmlStillReservesSpaceForCodevendor/bin/phpuniton PHP 8.5: 75 tests, 225 assertions, all green.