如何从字体文件中删除字符? [英] how to remove characters from a font file?
问题描述
我已经下载了 DejaVu开源字体,并希望将其用作WebFont,但是即使将其转换,我得到一个大文件,并且因为我将使用的网站只有几种语言(阿拉伯语,法语,amazigh),所以我不需要一些字符.
i've downloaded the DejaVu open source font and want to use it ad a WebFont, but even when converting it, i get a large file, and because the website i'll use will be only in few languages (arabic, french, amazigh) then, i dont need some characters.
有没有办法浏览字体文件并删除不需要的Unicode字符范围?
so is there a way to browse the font file and delete the unnecessary range of unicode characters that i'll not need?
推荐答案
我找到的最简单的方法是使用pyftsubset工具="noreferrer">字体工具.这是一个示例:
The easiest method I found is to use pyftsubset
tool from FontTools. Here's an example:
$ pyftsubset NotoSans-Regular.ttf \
--unicodes=U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116 \
--output-file=NotoSans-Regular.cyrillic.woff2 \
--flavor=woff2
注意:woff2
输出需要 Brotli .
我围绕它编写了一个简单的脚本,该脚本可自动执行整个过程,包括在分割字体文件后生成CSS文件.您可以在这里找到它: https://github.com/johncf/ttf2web
I wrote a simple script around it which automates the whole process including generation of a CSS file after splitting the font file. You may find it here: https://github.com/johncf/ttf2web
这篇关于如何从字体文件中删除字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!