Last active
November 10, 2023 06:57
-
-
Save shellj/e94be1a093177a41250a62a33b52ca59 to your computer and use it in GitHub Desktop.
fontforge 精简 fontawesome 字体
This file contains 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
# 需要使用 fontforge 的 ffpython 执行 | |
import fontforge | |
# 可以在 fontawesome.com 找到 glyph ,字体里面 glyphname 加了 uni 前缀 | |
glyphs = [ | |
"unif09a", #facebook | |
"unif099", #twitter | |
"unif16d", #instagram | |
"unie07b", #tiktok | |
"unif09b", #github | |
"unif167", #youtube | |
"unif2c6", #telegram | |
"unif0d2", #pinterest | |
"unif1b6", #steam | |
] | |
font = fontforge.open("C:\\Users\\aaa\\Downloads\\fontawesome-free-6.4.2-web\\webfonts\\fa-brands-400.woff2") | |
assert isinstance(font, fontforge.font) | |
selection = font.selection | |
assert isinstance(selection, fontforge.selection) | |
selection.all() | |
names = [] | |
for i in selection.byGlyphs: | |
assert isinstance(i, fontforge.glyph) | |
print(i.glyphname) | |
gly = i.glyphname.lower() | |
if gly not in glyphs: | |
font.removeGlyph(i) | |
else: | |
names.append(i.glyphname) | |
font.generate("C:\\Users\\aaa\\Downloads\\fontawesome-free-6.4.2-web\\webfonts\\fa-brands-400-sub.woff2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考这篇文章