Jim 的 TrueType 二维码字体
Jim's TrueType QR Code Font

原始链接: https://github.com/jimparis/qr-font

本项目提供了一种实验性的 OpenType 字体,它能自动将括号内的 ASCII 文本(例如 `[hello]`)转换为功能性二维码,同时保持周围文本的常规排版格式。 这些字体通过 Python 算法生成,集成了自定义的里德-所罗门(Reed-Solomon)纠错电路、模块布局以及源自 Liberation Sans 字体系列的字形轮廓。由于该过程依赖于 OpenType GSUB 特性调整,所生成的字体系列(QR Font 1-L, 2-L, 和 3-L)能够在兼容的环境中无缝显示标准文本和二维码符号。 用户可以通过指定不同的基础字体或调整二维码密度(最高支持 53 个字符)来自定义构建。该项目包含一个基于网页的演示程序以及供用户自行编译字体变体的完整工具。本项目采用 SIL 开源字体许可证,作为概念验证,展示了直接在排版中进行复杂数据编码的潜力。

```Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Jim 的 TrueType 二维码字体 (github.com/jimparis) 6 分,由 arantius 发布于 33 分钟前 | 隐藏 | 过往 | 收藏 | 1 条评论 帮助 ChrisArchitect 18 分钟前 [–] [重复] 最近的一条 Show HN: https://news.ycombinator.com/item?id=48703200 回复 指导原则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

Live Demo: https://qr.jim.sh/

Downloads:

This repo generates an experimental OpenType font that turns bracket-delimited text into a QR Code symbol while leaving surrounding text readable.

All fonts use:

  • Byte mode
  • Printable ASCII input
  • Fixed mask pattern 0
  • [ and ] as delimiters

The fonts are generated rather than hand-authored. The build script emits glyph outlines and GSUB feature logic, then compiles them into dist/qrfont-*.ttf. The default build compiles the delimiter parser, byte expansion, Reed-Solomon parity circuit, QR module placement, and fixed mask rendering.

Printable ASCII glyphs are copied from Liberation Sans Regular, scaled into the QR Font em square, so text outside bracketed QR blocks renders as ordinary text in the same font. Liberation is a reserved font name under the source font license, so the generated families are named QR Font 1-L, QR Font 2-L, and QR Font 3-L.

The project uses uv for Python dependency management. You can also run the generator directly with:

uv run tools/build_font.py

By default the generator reads Liberation Sans Regular from:

/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf

Use a different compatible TrueType source with:

uv run tools/build_font.py --base-font /path/to/BaseFont-Regular.ttf

To try the full generated Reed-Solomon circuit:

This is also the default make path. It emits thousands of contextual lookups and usually takes noticeably longer than a layout-only build.

For a faster layout-only build with placeholder zero parity:

To inspect the shaped glyph stream:

uv run tools/shape_debug.py '[a]' '[b]'

Outputs:

  • dist/qrfont-*.ttf (1-L, 2-L, and 3-L font files)
  • dist/index.html (interactive web demo)
  • build/qrfont-*.fea (generated OpenType feature files)

Open dist/index.html in a browser and type bracketed text such as [hello]. Mixed text such as abc[def]ghi should render as normal text, then a QR code for def, then normal text.

The generated font is a Modified Version of Liberation Sans Regular and is licensed under the SIL Open Font License, Version 1.1. See LICENSE-OFL.txt and NOTICE.md.

This is a proof-of-concept font. It relies on OpenType shaping, so it needs an environment that applies GSUB features to the font. Inputs inside a QR block are bounded to printable ASCII, up to 17, 32, or 53 characters depending on the selected font version.

联系我们 contact @ memedata.com