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?
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).