这是一个工作示例,它对 thumb_up
和 thumb_down
字形和连字进行子集化。
fonttools subset MaterialIcons-Regular.ttf \
--unicodes=5f-7a,30-39,e8db,e8dc \
--no-layout-closure \
--output-file=o.woff2 \
--flavor=woff2
这是什么意思:
-
--unicodes=5f-7a
:包括 _
的字形、字母 a-z
和数字 0-9
。据我了解,除非定义了单个字形 thumb_alt
、t
、h
、...,否则字体无法将 u
识别为连字(即使我们永远不会要求字体呈现单个字母字形)。
-
...e8db,e8dc
:指定子集中实际需要的字形。
-
--no-layout-closure
:仅包含我们需要的字形的连字(thumbs_up
和 thumbs_down
),而不包括任何其他可以从集合 _a-z
构造的连字,例如add
、delete
、face
等。如果没有这个选项,子集就会增长到几乎整个集合。
您可以检查生成的文件,例如在 fontdrop.info 上,它将显示 30 个字形和两个连字。您可以使用 the guide 中记录的文件,就我而言:
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url('../../fonts/o.woff2') format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}
要查找所需字形的 Unicode 值,您可以查看 codepoints file。
本文链接:https://www.f2er.com/1303288.html