Jim's QR Font Generates QR Codes Directly from Text Using OpenType Features
Jim's QR Font Generates QR Codes Directly from Text Using OpenType Features
Overview
Jim's QR Font is an experimental TrueType/OpenType font that turns bracket‑delimited ASCII strings into QR‑code glyphs while rendering the rest of the text normally. The technique relies on OpenType GSUB features, making QR generation possible directly in the text layout engine.
How the Font Works
- The font parses text surrounded by
[and]as a QR‑code payload. - Only printable ASCII characters are accepted; the payload length is limited by the font variant (17, 32, or 53 characters).
- The generator builds the QR code using byte mode, a fixed mask pattern (0), and Reed‑Solomon error correction.
- Glyph outlines for the QR modules are emitted programmatically; the surrounding printable ASCII glyphs are copied from Liberation Sans Regular and scaled to match the font’s em square.
- The resulting font family is named QR Font 1‑L, QR Font 2‑L, and QR Font 3‑L to avoid a naming conflict with the original Liberation font.
"All fonts use: Byte mode, Printable ASCII input, Fixed mask pattern 0,
[and]as delimiters" – project README.
Available Font Variants
| Variant | Module Grid | Max Characters |
|---|---|---|
qrfont-1L.ttf |
21 × 21 | 17 |
qrfont-2L.ttf |
25 × 25 | 32 |
qrfont-3L.ttf |
29 × 29 | 53 |
Each variant is distributed as a TrueType file in the GitHub releases page. The larger grids support longer payloads at the cost of a bigger visual QR symbol.
Building the Font
The repository provides a Makefile and a Python‑based build pipeline managed with uv. The default make target runs a full build that includes the Reed‑Solomon parity circuit, generating thousands of contextual lookups. For quicker iteration, a layout‑only build with placeholder zero parity is available via make fast-placeholder.
Typical build steps:
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Build the fonts (full parity)
make
# Or a faster placeholder build
make fast-placeholder
The generator expects Liberation Sans Regular at /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf. A different base font can be supplied:
uv run tools/build_font.py --base-font /path/to/YourBaseFont-Regular.ttf
Artifacts produced:
dist/qrfont-*.ttf– the three font files.dist/index.html– an interactive demo page.build/qrfont-*.fea– the generated OpenType feature files.
Using the Font
- Install one of the generated
.ttffiles on your system. - Open the demo page (
dist/index.html) or any application that supports OpenType shaping (e.g., modern browsers, word processors, or code editors). - Type normal text mixed with bracketed payloads, such as
abc[hello]ghi. - The surrounding characters render with the base glyphs, while the bracketed segment appears as a QR code.
"Mixed text such as
abc[def]ghishould render as normal text, then a QR code fordef, then normal text." – README.
Technical Details
- Byte Mode – The QR generator encodes each ASCII character as a single byte, simplifying the conversion.
- Fixed Mask Pattern 0 – Using a constant mask eliminates the need for runtime mask selection, which would be impossible in a static font.
- Reed‑Solomon Parity – Implemented as a series of OpenType contextual lookups, enabling error‑correction data to be embedded directly in the glyph stream.
- GSUB Feature Logic – The build script emits a substitution feature that replaces the delimiter sequence and payload with the appropriate QR‑module glyphs.
Limitations
- The font only works in environments that apply GSUB features; plain text renderers that ignore OpenType shaping will display the delimiters and payload as ordinary characters.
- Payload length is capped by the variant’s module grid (17, 32, or 53 characters).
- Only printable ASCII is supported; Unicode characters are not encoded.
- The font is a proof‑of‑concept and not intended for production use.
License
The generated font is a Modified Version of Liberation Sans Regular and is distributed under the SIL Open Font License v1.1. See LICENSE-OFL.txt and NOTICE.md in the repository for full terms.
Conclusion
Jim's QR Font showcases a creative use of OpenType shaping to embed functional QR codes directly in text streams. By converting bracketed ASCII into QR glyphs, the project demonstrates that complex data encoding can be achieved entirely within a font, opening possibilities for lightweight, code‑free QR generation in web and desktop environments.