Tool: Fontmin
Introduction
官网:http://ecomfe.github.io/fontmin/
Github:https://github.com/ecomfe/fontmin
The tool Baidu produced, known as the 第一个纯 JavaScript 字体子集化方案
natural thing has its own attractions, mainly for the following purposes:
- Extract some fonts
- Convert font format
- Generate webfont and corresponding CSS styles
Application scenario
Sometimes, we want to customize Chinese fonts for the site ’s Logo, Slogan, title, event page, etc. We can use @ font-face to introduce Web fonts, but the complete Chinese font library is 8M 10M, and the loading performance is very poor. So we extract some of the fonts we use, so that the font file can be turned into a few KB.
usage
var Fontmin = require('fontmin');
var fontmin = new Fontmin()
.src('fonts/*.ttf')
.dest('build/fonts');
fontmin.run(function (err, files) {
if (err) {
throw err;
}
console.log(files[0]);
// => { contents: <Buffer 00 01 00 ...> }
});
For detailed introduction and usage, please read this article: http://efe.baidu.com/blog/fontmin-getting-started/
Recommend several for you at the same time: Tools based on Fontmin
- fontmin-app -Fontmin desktop app, need to download and install
- gulp-fontmin -Gulp plugin for Fontmin
- font-spider -Automatically analyze WebFont used by pages and compress on demand
Tool: Web-fontmin
Introduction
Web fontmin : 网 :https://web-fontmin-app-ogrsynirlm.now.sh
Github :https://github.com/forsigner/web-fontmin
Web-fontmin is a font tool built on Fontmin, the main functions are:
- Extract fonts
- Font format conversion
The difference between fontmin and Web-fontmin
Web-fontmin is a combination of Squirrel + fontmin-app.
Squirrel only generates webfonts in different formats, and does not support Chinese. Web-fontmin can not only convert formats while supporting Chinese, but also extract fonts, and has faster upload and conversion speeds.
The main function of Fontmin-app is to extract fonts, which need to be downloaded and installed, and does not support Linux.
Web-Fontmin has all the functions of Fontmin-app and can be used online.