内置 TeX 语法高亮的字体
A font with built-in TeX syntax highlighting

原始链接: https://rajeeshknambiar.wordpress.com/2025/12/27/a-font-with-built-in-tex-syntax-highlighting/

在TUG2025会议上,展示了一种用于自动TeX语法高亮显示的新彩色字体。该字体受现有HTML/CSS高亮字体启发,为Prism.js或Pygmentize等较重的语法高亮工具提供了一种轻量级的替代方案。 该字体利用OpenType技术直接为TeX代码片段着色,支持COLRv0和COLRv1两种颜色格式。值得注意的是,它通过一组新颖的OpenType排版规则识别纯TeX、LaTeX2e和LaTeX3宏名称。该项目基于Coji Morishita的M+ Code Latin字体,旨在简化TeX文档中的代码呈现。 有关开发、使用和限制的更多详细信息,请参阅最新一期的*TUGboat*(46:2),字体二进制文件和源代码可在RIT字体仓库中获取。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 内置 TeX 语法高亮的字体 (rajeeshknambiar.wordpress.com) 6 分,由 LorenDB 发表于 2 小时前 | 隐藏 | 过去 | 收藏 | 1 条评论 punkpeye 4 分钟前 [–] 有趣的回应 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

At the TUG2025 conference, I presented a talk about the development of a new colour font, which does automatic syntax highlighting for TeX documents/snippets. The idea was floated by CVR, and was inspired by a prior-art of HTML/CSS syntax highlighting font by Heikki Lotvonen.

Syntax highlighting is achieved by specialized grammar files or packages on desktop applications, code editors, the Web, and typesetting systems like TeX. Some of these tools are heavy (e.g. prism.js or pygmentize package). A light-weight alternative would be a font that uses recent OpenType technologies to do syntax highlighting of code snippets. I developed such a font, for highlighting TeX code snippets.

Fig. 1: OpenType colour font doing syntax highlighting of TeX document.

There are some novelties in the developed font:

  1. It supports both COLRv0 and COLRv1 colour format specifications (separate fonts, but generated from the same source).
  2. Supports plain TeX, LaTeX2 and LaTeX3 macro names.
  3. A novel set of OpenType shaping rules for TeX syntax colouring.

The base font used is M+ Code Latin by Coji Morishita. The details of the development, use cases, and limitations can be found in the 46:2 issue of the TUGboat journal publication. The binary font and sources are available at RIT fonts repository.

联系我们 contact @ memedata.com