I have a Chinese font file, the size of the file is 7.693 MB. Due to the size of the ttf file, the website loads slowly.
Is there any way to reduce the size of the .ttf font?
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
There are a few ways to reduce the size of a TTF file, but most of them require that you know the consequences, since they are lossy.
Firstly, you can subset the font, which means to remove any glyphs (character images) that you don't need. If you have a font that covers several languages and you only need to support one language, then this can be for you. Or, if it has a lot of additional symbols and punctuation that you know you're not going to need, this is what you can do.
There are various services that can do this on a semi-automated basis, the most famous being the fontsquirrel @font-face generator (in expert mode, under custom subsetting). Unfortunately, this doesn't seem to have pre-defined ranges for Chinese characters so this seems like it may not be very easy for you. Or you can do so in your favourite font editor eg. FontForge.
Secondly, you can simplify the glyph in the font. Glyphs in a font are vector images, which consist of many line segments with control points where there are curves. You can often remove a lot of vertexes and control points while still somewhat preserving the overall shape. This has the effect of "simplifying" the curves. They lose accuracy, but they also reduce in file size.
Thirdly, you can remove some metadata from the font that you know you don't need. Given the font is over 7MB, I highly doubt that metadata is playing much into it here. Also, this is somewhat of an expert option.
And lastly, compressing the font using a lossless compression, for example from TTF to WOFF of WOFF2. WOFF2 has even better compression than WOFF, but anyone still on IE11 still can't use WOFF2 fonts so you may need to fall back to WOFF for those.
It's important that you understand that doing any of the above to the font (apart from the last one) has consequences in how well the font works or how many languages it supports properly, so you need to do a lot of testing.
One final important point is that by doing any of the above to the font (including, surprisingly, simply converting it to WOFF or WOFF2), you are legally creating a derivative work, for which you specifically need a license to do so from the font's author. Most commercial fonts probably won't let you create derivative works. A notable exception is an open license like the SIL OFL which specifically permits derivative works (if you change the name of the font).
I don't know if you speak Chinese or not, but in case you know what you are doing, you could subset the font and reduce it to the 3000-4000 most used glyphs. This should be enough to render most standard Chinese texts and could significantly reduce the file size (a Chinese font might come with over 20,000 glyphs). Do this only in case you master Chinese at least on an intermediate level or have someone who could help you identifying the subset of glyphs required for your purpose.
Here's a frequency list for the characters used in Mainland China. Unfortunately it is somewhat outdated (2004). It only contains 3500 characters, use it with caution. (the Xinhua Zidian lists approx. 10,000 characters and it is the most common character dictionary you will encounter in China). Given names might have any character, so a 3500 glyph subset will only cover the everyday language. Again, this is only for Mainland China. Taiwan and some overseas communities use other characters (the traditional ones). If you are not a Chinese speaker, you will need someone with expertise on this.