Linux command
fonttools-subset 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Subset
fonttools subset [path/to/font.ttf] --unicodes=U+0000-007F
Example
fonttools subset [path/to/font.ttf] --unicodes=U+0000-007F --flavor=woff2
Example
fonttools subset [path/to/font.ttf] --unicodes=U+0000-007F --layout-features=onum,kern
Example
fonttools subset [path/to/font.ttf] --unicodes=U+0000-007F --output-file=[path/to/subset.ttf]
说明
fonttools subset generates optimized subsets of font files by including only specified glyphs, Unicode ranges, or OpenType features. This is essential for web font optimization, reducing file sizes significantly by removing unused characters. The tool supports TrueType (.ttf), OpenType (.otf), WOFF, and WOFF2 formats. It can convert between formats during subsetting using the --flavor option. Common use cases include creating language-specific subsets, web-optimized fonts with only Latin characters, or icon fonts with specific glyphs.
参数
- --unicodes=_RANGE_
- Unicode code points to include (e.g., U+0000-007F for Basic Latin)
- --flavor=_FORMAT_
- Output format: woff, woff2, or omit for original format
- --layout-features=_LIST_
- Comma-separated OpenType features to keep (e.g., kern,liga,onum)
- --output-file=_PATH_
- Specify output filename; defaults to input with .subset suffix
- --text=_STRING_
- Include only glyphs needed for the given text
- --text-file=_FILE_
- Include glyphs needed for text in the specified file
- --no-hinting
- Remove hinting instructions to reduce file size
- --desubroutinize
- Remove subroutines from CFF fonts
FAQ
What is the fonttools-subset command used for?
fonttools subset generates optimized subsets of font files by including only specified glyphs, Unicode ranges, or OpenType features. This is essential for web font optimization, reducing file sizes significantly by removing unused characters. The tool supports TrueType (.ttf), OpenType (.otf), WOFF, and WOFF2 formats. It can convert between formats during subsetting using the --flavor option. Common use cases include creating language-specific subsets, web-optimized fonts with only Latin characters, or icon fonts with specific glyphs.
How do I run a basic fonttools-subset example?
Run `fonttools subset [path/to/font.ttf] --unicodes=U+0000-007F` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --unicodes=_RANGE_ do in fonttools-subset?
Unicode code points to include (e.g., U+0000-007F for Basic Latin)