Font Subsetting done right.
Experimantal font subsetting tool, which is optimized for CJK.
- There are a lot of Ideograph, Hangul letters.
- Most of Ideograph letters are infrequently used.
Group letters by its usage frequency and subset them into many chunks using unicode-range
property in @font-face
.
- This script didn't put ligatures into consideration and may break some font features.
- The CSS file (w/ unicode-range) is not optimized as
unicode-range
haven't taken into consideration.
$ git clone https://github.com/HelloWorld017/fontsetify.git
$ cd fontsetify
$ npm i
$ pip install fonttools brotli zopfli # Install pyftsubset
$ npm start # Generate folders, config
$ cp ~/my-fonts/*.ttf fonts/ # Copy your fonts into fonts/ directory.
$ npm start
$ ls -al ./output # Subsets and the Stylesheet are generated.
Prioritized. For each options, select glyphs in remaining glyphs and group them.
Example:
"groupBy": [
"ideograph-frequency",
"ideograph-strokes",
"hangul-2350-11172",
"unicode-blocks",
"all"
]
Group Ideograph Letters into 5 groups by its frequency.
A rough frequency measurement for the character based on analysis of traditional Chinese USENET postings; characters with a kFrequency of 1 are the most common, those with a kFrequency of 2 are less common, and so on, through a kFrequency of 5.
Please refer to unihan.
Group Ideograph Letters by its stroke counts.
Group Jouyou Kanji first, and group other Ideograph Letters.
Group 2350 Hangul Letters (KS X 1001) first, and group other Hangul Letters.
Group 2574 Hangul Letters (KS X 1001 + Additional 224) first, and group other Hangul Letters.
Please refer to this paper (Proposal for Additional Korean Characters in Complete Code System of Hangeul
).
Group letters by Unicode Blocks.
Group all letters into one group.
Keep glyphs in each chunk less than this value.
If it is true, collect small chunks which size is less than the chunkSize and make a larger chunk.
Infer font weight by its file name.
Example:
"weightByFileName": {
"black": 900,
"extrabold": 800,
"bold": 700,
"semibold": 600,
"medium": 500,
"regular": 400,
"medium": 400,
"semilight": 300,
"demilight": 300,
"light": 200,
"extralight": 100,
"hairline": 100
}