Skip to content

feat(qr-code): qr code enhancements and goodies - #2646

Merged
rkaraivanov merged 8 commits into
masterfrom
rkaraivanov/qr-code-enhancements
Nov 23, 2026
Merged

rkaraivanov merged 8 commits into
masterfrom
rkaraivanov/qr-code-enhancements

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

Description

  1. Encoding: the encoder splits the value into numeric, alphanumeric and byte segments with the fewest bits. A value that mixes long runs of digits or uppercase letters with other text can get a smaller version.
  2. Payloads: createWifiPayload(), createVCardPayload(), createEpcPayload() and createEventPayload() in the new igniteui-webcomponents/extras/qr-payloads entry point. This commit also moves chat-markdown-renderer and combo-data-source into their own folders under src/extras/, each with a README.
  3. Geometry: each module covers whole pixels, so the edges are sharp. The spare pixels widen the quiet zone. The alignment patterns take the corner shapes and have an alignment part. This also fixes codes with a circle corner square, which zxing-cpp could not always read.
  4. Shapes: dot-style takes diamond, plus, liquid, horizontal-bars and vertical-bars. square-style and corner-dot-style take leaf.
  5. Paint and logo: gradient and gradient-angle paint the modules with a linear or radial gradient from --ig-qr-code-gradient-start to --ig-qr-code-gradient-end. logo-shape clips the logo to a circle, rounded or squircle shape, and the code removes only the modules under that shape.
  6. Refactor: each dot style is one entry in a table that holds its corner dot, its join rule and its paths.
  7. Stories: each shape and color option shows at a size where the differences are clear. A new Gradient story has color pickers for the two gradient colors.

Existing codes render differently. The code can be smaller than size, rounded modules end round at the logo cutout, and some values get a smaller version. All of them still scan. No API is removed.

The igc-qr-code bundle goes from 17,628 B to 20,991 B gzip. The payload helpers are 1,786 B gzip in their own entry point.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)

Testing

  • The scan specs decode the PNG that toImage() exports with zxing-cpp (zxing-wasm), at 6 pixels per module or more. Each new shape, gradient and logo shape has a scan spec, some also on a version 12 code.
  • With the old geometry, a circle corner square decoded 180 of 196 times with a square dot, and 190 of 196 times with the other dots (versions 3 to 25, 6 to 12 pixels per module). Now all 2,240 scans of the 16 corner shape pairs pass.
  • 394 QR code and payload specs pass in Chromium. The QR code specs also pass in Firefox and WebKit.

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have updated documentation if needed
  • If I changed the public API on purpose, or its JSDoc, I have run npm run public-api:update and committed public-api.json and api-reference/
  • I have added a CHANGELOG.md entry under [Unreleased]

Split the value into numeric, alphanumeric and byte segments with the
fewest bits, by a shortest path over the characters for each count
field width group. Neighbors that tie on bits merge into one segment.
A value with a long digit or uppercase run in other text can get a
smaller version.

Export the QrCornerDotStyle type. Document that the code writes UTF-8
with no ECI header. The single-mode property spec now checks the bits
against the best single mode. New properties check the version of
mixed data and decode the matrix with zxing, through a shared
prepareQrDecoder() helper that the component spec also uses.
Add igniteui-webcomponents/extras/qr-payloads with createWifiPayload(),
createVCardPayload(), createEpcPayload() and createEventPayload(). Each
builds the value of a code that a phone turns into an action, escapes
the text, and throws a RangeError for input that its format does not
allow. The formats are WIFI:, vCard 3.0, EPC version 002 in UTF-8, and
an iCalendar VEVENT in UTC. Property specs read the escapes back with
independent parsers.

Move each extra into its own folder with a README that the main README
links, and give the payload helpers a specification. The subpaths do
not change.

The Generator story uses the helpers and adds a payment and an event.
New stories show the mailto:, tel:, SMSTO: and geo: recipes and a
"Scan me" frame. The QR scan specs share readQr() and readQrMatrix().
…atterns

Each module covers floor(size / (modules + 2 * margin)) whole pixels,
on the screen and in an export at size * scale. The spare pixels widen
the quiet zone, so margin is a minimum and the code can be smaller than
size. A fractional margin can make each module 1 pixel smaller, so that
both sides keep the minimum. A transform on the code group and the
logo does the snapping, so the viewBox stays 0 0 n n.

Draw each alignment pattern as a ring of square-style around a dot of
the corner dot style, in a new alignment part that takes
--ig-qr-code-dark-color. A rounded module no longer joins it.

Fix square-style="circle" codes that failed to scan at some sizes.
zxing-cpp checks the finder pattern on its diagonals, where a square
dot leaves a gap, and it did not find the alignment modules between
circle dots. A square corner dot in a circle corner square now draws
as a circle, and with the alignment rings the circle codes decode.
dot-style takes diamond, plus, liquid, horizontal-bars and
vertical-bars. liquid fills the inside corner of each L-join of
rounded modules, and a bar style draws each run of dark modules in a
row or a column as one bar with round ends. Each style decodes at the
0.7 dot-scale floor, with each corner square.

square-style and corner-dot-style take leaf: two opposite corners
rounded at a quarter of the side, on the diagonal toward the center of
the code. A fully round leaf failed to scan with zxing-cpp.

A corner dot is one shape, so the corner dots draw diamond and plus as
square, because both failed to scan as finder centers, and liquid and
the bar styles as rounded. A circle corner square also draws a leaf
corner dot as a circle.
gradient paints the modules and the corners with a linear or radial
gradient, from --ig-qr-code-gradient-start to --ig-qr-code-gradient-end.
gradient-angle turns a linear gradient. An explicit corner color wins
for its part, and the export writes the stop colors.

logo-shape clips the logo to a circle, rounded or squircle shape that
fills the logo box. The cutout removes only the modules under the
shape, so a pinned version can keep a larger logo.

With a logo, rounded, liquid and bar modules end round at the cutout
instead of being cut straight. The hidden modules stay under the mask.
Each dot style is now one entry in a table: its corner dot, whether its
modules join, and how it draws them. The data modules read a grid of
dark cells and zones, and the templates take one grid object. Pixel
snapping moved to its own file.

The part selectors match a word in `part`, and bars draw with two arcs.
The other dot styles get the Latin square scans of the basic ones.
@rkaraivanov rkaraivanov added enhancement New feature or request squash-merge QR labels Nov 23, 2026
@rkaraivanov
rkaraivanov merged commit f9ac20d into master Nov 23, 2026
10 checks passed
@rkaraivanov
rkaraivanov deleted the rkaraivanov/qr-code-enhancements branch November 23, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request QR squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant