我有一个 14MB 的 TTF,主要包含简体中文字符。
我想通过创建一个仅包含 HTML 页面中特定字符的子集来减小大小。
因此,理想情况下,我想向 (Linux) 程序传递一段文本,并让它根据包含的字符重新创建字体。
例如
./magic-font-squisher input.tff "ABC123水小长"
或
./magic-font-squisher input.tff /path/to/test.html
新字体将仅包含这 9 个字符。
最佳答案
您可以通过 scripting FontForge 来完成。这是可行的,尽管它可能会变得更聪明或包含在包含脚本中。
#!/usr/bin/env fontforge
Open($1); # first param
SelectAll();
SelectFewer(0u41, 0u43, 0u31, 0u33); # a range
SelectFewer(0u6c34); # or a single codepoint
SelectFewer(0u5c0f);
SelectFewer(0u957f);
DetachAndRemoveGlyphs();
Save($2); # second param
Quit(0);
在运行之前我必须定义FONTFORGE_LANGUAGE
:
FONTFORGE_LANGUAGE=ff ./squish source.ttf squished.ttf
关于unicode - 按特定字形划分字体子集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16673426/