减小 .ttf 字体大小的方法?
有什么方法可以减小 .ttf 字体的大小吗?即如果我们想删除一些我们没有使用的字形。
Is there any way to reduce the size of the .ttf fonts? i.e. if we want to remove some glyps which we are not using.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
FontSquirrel 的 Webfont 生成器 可以非常轻松地减小字体的文件大小。
我能够将 263kb 字体缩小到 34kb。
FontSquirrel's Webfont generator makes it very easy to reduce a font's filesize.
I was able to take a 263kb font down to 34kb.
使用 Google 网页字体,您可以限制字符集,例如:
如果 Google 有图标,这将特别有用类似 Font Awesome 的字体
With Google Web Fonts, you can limit the character set like:
This would be particularly useful if Google had icon fonts like Font Awesome
您可以使用 fonttools 从字体中删除不需要的字形。
mySmallerFont.ttf 将仅包含从 U+0020 到 U+007E(基本拉丁语)的 unicode 字符。
完整文档可在此处获取。
有关 unicode 字符列表,您可以查看维基百科。
You can use fonttools to remove unwanted glyphs from a font.
mySmallerFont.ttf will contain only unicode characters ranging from U+0020 to U+007E (basic latin).
Full documentation is available here.
For the list of unicode characters, you can check Wikipedia.
您可以使用 fontforge 来减小文件大小
这在 http://www.cnx-software.com/2010/02/19/reducing-truetype-font-file-size-for-embedded-systems/
You can use fontforge to reduce the file size
This is explained at http://www.cnx-software.com/2010/02/19/reducing-truetype-font-file-size-for-embedded-systems/
我执行了以下操作,从字体中删除所有西里尔字母(字母),因此将文件大小减少一半,因为我只需要拉丁字母。
请考虑我不是这方面的专家。但我需要一个快速的解决方案。
您可以在这里阅读有关此主题的更多信息:http://wiki.unity3d.com/index.html php?title=Create_a_new_TrueType_font_using_a_subset_of_characters_from_an_existing_TrueType_font
I did the following to remove all Cyrillic glyphs (letters) from a font, hence cutting file size in half as I only needed the Latin letters.
Please consider that I am not a pro in this. But I needed a fast solution.
Here you can read more on this topic: http://wiki.unity3d.com/index.php?title=Create_a_new_TrueType_font_using_a_subset_of_characters_from_an_existing_TrueType_font
我使用 fontmin 从 ttf 字体中删除字形。
它成功地将 Noto Sans(粗细=中等)从 20MB 减少到不到 10,但仍然涵盖常见的中文/日文字符。
I was using fontmin to remove glyph from ttf fonts.
It succeeded to reduce Noto Sans (weight=medium) from 20MB to less than 10, yet still cover common Chinese/Japanese characters.
这有什么应用?大多数字体都相对轻量。 TTF 存储矢量数据而不是位图数据,因此描述每个字形的形状需要相对较少的字节。即使非常繁忙的字体也可以保持在 100kb 以下。许多现代字体都带有 ClearType 提示,但即使这样也只会增加很少的文件大小。
如果您确实想从字体中删除某些字形,那么您将需要一个字体编辑工具(Macromedia 有一个名为 Fontographer 的工具,现在由 FontLab 所有)。但您最好选择较浅的字体。例如,
OCR A Std
只有 30kb,并且包括 ClearType 提示以及所有 US ASCII 字符。尽量避免使用 Unicode 字体,因为完整的 Unicode 支持需要大量的字形。但大多数字体不提供完整的 Unicode 支持。最后,如果您决定修改字体,请确保将其命名为其他名称。命名冲突可能会给用户带来一些非常恼人的意外。
What is the application for this? Most fonts are relatively lightweight. TTFs store vector data instead of bitmap data, so it takes relatively few bytes to describe the shape of each glyph. Even very busy fonts can be kept below 100kb. Many modern fonts come with ClearType hinting, but even this adds very little file size.
If you really want to take certain glyphs out of a font, then you will need a font editing tool (Macromedia had one called Fontographer that is now owned by FontLab). But you're probably better off just picking a lighter font. For example,
OCR A Std
is only 30kb and includes ClearType hinting as well as all US ASCII characters. Try to avoid Unicode fonts since full Unicode support requires a ton of glyphs. But most fonts don't offer full Unicode support.Lastly, if you do decide to modify a font, make sure you name it something else. A naming conflict could result in some really annoying surprises for users.