Repository navigation
修复 macOS 下 LuaLaTeX 找不到已下载的楷体和仿宋 - #517
Merged
Merged
Conversation
When fontspec cannot resolve Kaiti SC or STFangsong by name, look for the installed files in macOS font assets. Select the regular and bold SC faces for both body italics and the Kai family. Extend the macOS font regression sample to exercise the named Kai and Fangsong families.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
zepinglee
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #516
在本机通过字体册下载楷体和仿宋后,两个字体文件都位于
/System/Library/AssetsV2/com_apple_MobileAsset_Font8/下。在master的8f11ebf上清除OSFONTDIR后,同一个示例用 XeLaTeX 可以编译,用 LuaLaTeX 则在加载文档类时报告The font "Kaiti SC Regular" cannot be found。修改
使用 macOS 中文字体配置时,LuaLaTeX 先按名称查找楷体和仿宋。某一字族查找失败时,再到
AssetsV2及其PreinstalledAssetsV2/InstallWithOs子目录中的字体资源包查找该字族的文件。目录名中的版本号和各资源包的标识由运行时读取。这个查找方式参考了 CTeX 对 macOS 字体目录的处理。正文斜体和
\kaishu共用Kaiti.ttc的简体常规和粗体字形,索引分别为 0 和 3。中文等宽字体和\fangsong使用STFANGSO.ttf。用户可以直接用 LuaLaTeX 编译已有文档。验证
在 macOS 27.2.1(26B131,Apple Silicon)、TeX Live 2026、LuaHBTeX 1.24.0、luaotfload 3.29 上实测。下面的
fontcheck.tex也可以用于旧版 macOS 复核。OSFONTDIR后,示例一次编译通过。pdffonts显示 PDF 嵌入了STKaitiSC-Regular、STKaitiSC-Bold和STFangsong。另外分别让楷体或仿宋可按名称找到,两种情况下的字体样张都与原版加OSFONTDIR的输出一致。OSFONTDIR后执行latexmk -lualatex main.tex,官方示例共 32 页。与同一版master手动设置OSFONTDIR的输出逐页比较,96 dpi 灰度渲染完全一致。make test的 51 项回归测试通过。另行执行l3build check -c build fontset-mac,通过了包含\kaishu和\fangsong的 XeLaTeX 专项测试,也用 LuaLaTeX 编译了这一用例。常规回归所需的 Fandol 字体和 Biber 拼音排序模块在临时测试目录中补齐。