Repository navigation
Releases
1.3.0
Bars4J 1.3.0
Fixed
- Matrix SVG/HTML canvas for rectangular symbols: the
MatrixBarcodeFormatwrapper (Java and Node) sized both canvas dimensions fromwidthInModules, letterboxing rectangular matrix symbols — the PDF417 SVG carried a 564x564 canvas around a 564x48 symbol. Width and height are now computed separately fromwidthInModules/heightInModules; square formats (QRCode, Data Matrix, Aztec) are unaffected. - Node matrix
toSvgdocument assembly still used the old Java wrapper format (viewBox, no fallback text); it now mirrors the current JavaSvgDocument(fixed canvas,xMidYMidalignment, fallback text), so the matrix end-to-end SVG fixtures are byte-identical between Java and@bars4j/coreagain. RenderSpec.fontSizenow honoured by every output path — the SVG document style, the HTML snippet style and the raster label all follow the spec (defaults preserved: 14 px when unspecified).- Anti-aliased raster label glyphs: the human-readable label band now renders with text anti-aliasing enabled (grayscale), removing the hard jaggies on the label font.
Changed
- Gallery trimmed to the README showcase samples:
images/now keeps only the 23 SVG samples presented in the README (and their locally generated PNG counterparts, still git-ignored);EAN5.svgand theEAN13-font-*.svgdemo samples were removed from the repository. images/PDF417.svgregenerated (564x48; the tracked sample predated the PDF417 encoder rewrite).- New
MatrixCanvasTestpins the canvas-to-raster geometry parity for every matrix format.
Notes
- Maven Central publishing is now fully automated (
autoPublish=true+waitUntil=published): a published release deploys, validates and publishes on the Central Portal without manual approval. @bars4j/core1.3.0 ships the same conformance guarantees: 175 Node tests, 48/48 HTML snippets byte-identical with the Java output.
Full changelog: pr-1.1.0...pr-1.3.0
1.1.0
Bars4J 1.1.0
Added
- Inline HTML/SVG snippet for the Node.js port (
toHtml): the@bars4j/corepackage now offers the same entry points as the Java library —BarcodeGenerator.of(id).toHtml(text)for the natural size andtoHtml(text, displayWidth, displayHeight)for an explicit display size. The snippet has no XML prologue, carries aviewBox(scales with its container),role="img"and an escapedaria-label, and its drawing markup is byte-for-byte identical to the golden-validatedtoSvgoutput. Verified against the Java implementation for all 24 registered formats, at natural and explicit display size (48/48 identical). AGENTS.mdintegration guide for AI coding agents (format ids, output API,RenderSpecbounds, exceptions, JPMS notes, pitfalls).- Shared
org.bars4j.encode.matrix.ecclayer (GfField+ReedSolomonCoder) unifying the GF(2^m) field and Reed-Solomon arithmetic across QR Code, Data Matrix and Aztec (~−214 duplicated lines; both GF(256) polynomials now documented and cached viaGfField.of). EAN5.svgadded to the demo samples.
Changed
- Linear renderers refactored behind a shared
BarRect+LinearPainterspipeline (renderers now only decide geometry; raster/SVG painting is centralized), with a sharedSvgDocumentassembly for the standalone SVG output. Pixel-exact ink coverage preserved for all 20 linear formats. - Node 1D renderers mirror the Java
BarRectpipeline (one absolute SVG subpath per element, inks separated per colour).
Fixed
- PostNet SVG bars were drawn below the 12 px canvas (y=20..28); restored the bottom-aligned rule at the baseline.
- ITF-14 wide ratio was hardcoded to 2.0, ignoring the format's registered 2.5 — the canvas shrank from 155 to 126 px; the ratio is now read from the spec.
module-info.javanow declaresrequires java.logging;, restoring the modular build.- Data Matrix GF(256) polynomial comment corrected (0x12D = x^8+x^5+x^3+x^2+1; QR uses 0x11D).
Full changelog: pr-1.0.1...pr-1.1.0
1.0.1
Bars4J 1.0.1
Fixed
- HRI label alignment on the scaled raster path: when the x-dimension was not an exact multiple of the minimum (e.g. the
0.26default shown by the Swing demo), the bars were compressed but the human-readable text was drawn with unit-width slots — the last EAN/UPC digit drifted 1–2 px into the right-hand guard bars. Slot positions are now computed with the fractional module width in double precision, so the digits keep lining up with the bars for any x-dimension. - EAN/UPC slot positions are now relative to the leading quiet zone, keeping the label aligned for non-default quiet-zone widths.
- The centred label no longer scales its font with the x-dimension, which could wipe the ITF-14 bottom bearer bar.
Full changelog: pr-1.0.0...pr-1.0.1
1.0.0
Bars4J 1.0.0
HRI label alignment fix
The human-readable digits of the EAN/UPC formats are now drawn digit-by-digit in fixed 7-module slots (the canonical HRI positions), so the label no longer collides with the right guard bars regardless of JDK font metrics.
New rendering options
RenderSpecnow accepts the quiet zone width (modules per side, default 10) and the human-readable label font size (default 14).SwingDemoexposes the new options plus a fixed Colours panel.
Legacy API removed
The retired legacy API (Barcode, BarcodeFactory, BarcodeComponent, org.bars4j.paint, legacy encoders) has been removed. Use the unified BarcodeGenerator facade — see the README migration examples.
Full changelog: pr-0.9.0...pr-1.0.0
0.9.0
What's Changed
Security hardening
This release hardens the rendering pipeline against untrusted input:
- XSS: untrusted text is now escaped in every legacy painter, so SVG/HTML output is safe even when the human-readable label contains markup characters.
- Text cap: text longer than 4000 characters (globally settable/resettable via
setMaxTextLength/resetMaxTextLength) now throws the library's checked exceptions instead of producing unbounded output — in both Java and Node. - RenderSpec bounds:
barWidth(≤ 100),barHeight(≤ 10 000) andmoduleSize(≤ 100) are validated in Java and Node, with integer checks on the Node side. - Code 128 is encoded with a fixed charset (ISO-8859-1) in both implementations, removing platform-dependent default-charset behaviour.
- CI: all GitHub Actions are pinned by commit SHA and npm is pinned to 11.5.1 in the workflows.
- Registry:
register()no longer allows shadowing a registered format id, and id normalisation uses an explicit locale (Locale.ROOT) in Java. - module-info exports are narrowed to the public API surface.
Rendering fixes
- EAN/UPC labels are padded defensively before fixed-offset
substringcalls, so short labels can no longer crash withStringIndexOutOfBoundsException. - The human-readable text area now honours the
RenderSpecbackground via a new spec-awarepaintTextSvg/paintTextWithSpec(previously hardcoded#fff, which broke the visual on dark backgrounds) — in both pipelines. - SVG output emits
preserveAspectRatio="xMidYMid meet"and normalises#fffto#ffffff(goldens regenerated accordingly).
Improved
- The user
RenderSpecis now fully propagated through the Node linear format: colours from the user spec reach the bar renderers and the text renderers, matching the Java behaviour end-to-end. - The Node
package-lock.jsonis back in sync withpackage.json.
Tests
SecurityHardeningTest(12 tests) covers the spec bounds, the text cap, the registry rule, label padding and legacy XSS escaping.- A new Node test verifies spec colours in the raster pixels and SVG fills — 729 Java tests + the performance integration test, 98 Node tests, all green.
Full Changelog: pr-0.8.0...pr-0.9.0
0.8.0
What's Changed
New: inline HTML/SVG embedding (toHtml)
Every registered format (1D and 2D) can now be rendered as an SVG snippet ready to be pasted directly into a web page — no XML prologue, no generator comment, no fallback text — with a viewBox (so it scales with its container), role="img" and an aria-label:
String html = BarcodeGenerator.of("EAN13").toHtml("789100031550");
// paste directly inside <body>...</body>
String sized = BarcodeGenerator.of("CODE128").toHtml("Bars4J-128", 300, 100); // explicit px sizeThe drawing markup inside the snippet is byte-for-byte identical to the validated toSvg output (guarded by a parity test across all 24 formats). toSvg and the raster output are unchanged.
Fixed
- Encoder bugs across the 1D and matrix encoders: null-text handling now throws the library's checked exceptions,
EANEncoder.charToIntno longer leaks aNumberFormatException, Code 11 check-digit pairs and the Code 39 full-ASCII shift handling are corrected. - The orphan moveto in the width-coded SVG path (
zm2 0 0h1→zm2 0h1) is fixed. &,<and>are now escaped in the human-readable SVG text (Code 128's charset allows them, which used to break the markup).
Improved
- The
RenderSpeccolours are honoured end-to-end — raster, SVG and human-readable text (previously ignored for linear formats). - DPI metadata: PNG embeds a
pHYschunk and JPEG a JFIF density tag, so generated images carry their true physical size (GIF has no DPI support). BarcodeComponent(Swing): null text is rejected, state is validated before mutation,getPreferredSize()derives from the rendered image and the last valid image is kept on failure.- Resource hygiene:
dispose()on everyGraphics2D, holder idiom across the legacy painters, a synchronized immutableBarcodeRegistryand try-with-resources in the demo.
Tests
- 77 new tests covering the HTML snippet (structure, parity with
toSvg, spec colours, escaping), encoder spec vectors (Code 11, PostNet, UPC-E, Code 39 Extended, PDF417, ECI/GBK, QR fullwidth), raster/SVG colour conformance and the Swing component — 717 unit tests + the performance integration test, all green.
Full Changelog: pr-0.7.3...pr-0.8.0
0.7.3
What's Changed
- Keep a 2px gap between the bars and the human-readable text in the raster (PNG) output for EAN13, EAN8, UPCA, UPCE and EAN5. SVG output is unchanged.
- Root README now has a Quick Start covering both the Java and the Node.js versions.
- The Node README no longer carries the npm publishing instructions.
Full Changelog: pr-0.7.2...pr-0.7.3
Bars4J 0.7.2
Bars4J 0.7.2
Maintenance release aligned across Java and Node, and the first release that ships the built Java
jars as downloadable assets.
Java
org.bars4j:bars4j:0.7.2published to GitHub Packages.- Release assets now include the built jars:
bars4j-0.7.2.jar(library) and
bars4j-0.7.2-sources.jar(sources). - The Maven publish workflow now attaches the jars to the release automatically.
Node.js / TypeScript (@bars4j/core)
@bars4j/core@0.7.2published to the public npm registry via trusted publishing (OIDC) with
automatic provenance — no npm token is stored in the repository.
CI fixes
- Maven publish triggers only on the release
publishedevent (no more duplicate runs). - Node publish uses OIDC only (token secret removed) and upgrades npm so trusted publishing works.
Bars4J 0.7.1
Bars4J 0.7.1
Patch release that carries the same content as 0.7.0 — the initial 0.7.0 Maven deploy hit an
existing artifact version in GitHub Packages — published with the Maven workflow fixed to run a
single time per release.
Contents
- Node.js / TypeScript port (
@bars4j/core), including 1D + 2D formats, SVG and raster output,
demos, abars4jCLI and Node CI/publish workflows. See the
0.7.0 release notes for details. - Maven publish fix: the workflow now triggers only on the release
publishedevent (instead of
published+created), so a release no longer produces duplicate runs that race to deploy the
same artifact version (409 Conflict).
Notes
- Java and Node versions are aligned at 0.7.1.
- The Java sources are unchanged.
Bars4J 0.7.0
Bars4J 0.7.0
Adds a complete Node.js/TypeScript port of the library, published as
@bars4j/core on npm, while keeping the Java library
and its golden fixtures in sync.
Node.js / TypeScript port (node/)
- 1D: all 20 linear formats with byte-for-byte identical SVG output.
- 2D: QRCode, Data Matrix, PDF417 and Aztec, including their SVG output.
- Raster: dependency-free ARGB geometry and PNG export; the optional
@napi-rs/canvasbackend draws the
human-readable text. - Demos and CLI:
npm run demo/npm run demo:qrcodeand abars4jcommand-line tool. - Packaging and CI: npm metadata, Node CI (Node 22/24,
npm packcheck, demo smoke test) and a
publish workflow using npm trusted publishing. - Verified with 96 tests against the shared Java goldens: 1D SVG goldens, 1D raster image
fingerprints, 2D module-matrix/SVG goldens and an all-formats smoke test. - New fixtures under
src/test/resources/golden/matrix(2D matrices, 2D SVGs, QR Kanji case),
generated from the unmodified Java implementation.
Notes
- The Node package requires Node.js 22.18+ and needs no build step (native TypeScript type stripping).
- The Java sources are unchanged.