当前位置:网站首页>字体压缩神器font-spider的使用
字体压缩神器font-spider的使用
2022-07-31 02:33:00 【浩星】
前言:
很多时候项目会遇到需要引入外部字体,不管是vue,小程序,react等等,但是pc端项目还好,把源文件放我们本地是可以的,小程序就不行了,因为体量比较小,对大小有限制。
font-spider 字蛛 官网地址:最好有翻墙软件,不然太慢了,大概率不成功
font-spider.org - http://ww1.font-spider.org/
具体使用:
1、全局安装插件
npm install font-spider -g
2、检查有没有安装成功
font-spider -V
3、打开你的目录,找到你的源文件在的文件夹,比如我的
4、新建一个index.html,
注意LouisVuittonGlobal-Regular 等名字换成你自己的源文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>font spider</title>
<style>
@font-face {
font-family: 'LouisVuittonGlobal-Regular';
src: url('./LouisVuittonGlobal-Regular.eot');
src:
url('./LouisVuittonGlobal-Regular.eot?#font-spider') format('embedded-opentype'),
url('./LouisVuittonGlobal-Regular.woff') format('woff'),
url('./LouisVuittonGlobal-Regular.ttf') format('truetype'),
url('./LouisVuittonGlobal-Regular.svg') format('svg');
font-weight: normal;
font-style: normal;
}
.medium {
font-family:'LouisVuittonGlobal-Regular';
}
@font-face {
font-family: 'LV_Global_Demi';
src: url('./LV_Global_Demi.eot');
src:
url('./LV_Global_Demi.eot?#font-spider') format('embedded-opentype'),
url('./LV_Global_Demi.woff') format('woff'),
url('./LV_Global_Demi.ttf') format('truetype'),
url('./LV_Global_Demi.svg') format('svg');
font-weight: normal;
font-style: normal;
}
.bold {
font-family:'LV_Global_Demi';
}
</style>
</head>
<body>
<div>
<!-- 这里对应的是Bold的压缩包 -->
<div class="bold">
abcdefghijklmnopqrstuvwxyz
</div>
<!-- 这里对应的是Medium的压缩包 -->
<div class="medium">
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</div>
<!-- 这写在class元素之外的就没有对应的压缩包了 -->
0123456789
</div>
</body>
</html>
5、右键打开cmd弹框,或者powershell弹框,执行命令
font-spider index.html
6、可以看到下面的界面,源文件2M,压缩以后是60k左右,还有其他格式可以用
7、美滋滋把,用起来,css引入:
@font-face {
font-family: 'LouisVuittonGlobal-Regular';
src: url("../fonts/LouisVuittonGlobal-Regular.ttf") format('truetype'); //主要是这句话
font-weight: normal;
font-style: normal;
}
边栏推荐
- 局域网电脑硬件信息收集工具
- coldfusion8 background scheduled tasks take shell
- How to do a startup CTO?
- STM32CUBEMX develops GD32F303 (11) ---- ADC scans multiple channels in DMA mode
- The principle of complete replication of virtual machines (cloud computing)
- Drools基本介绍,入门案例,基本语法
- 10 权限介绍
- leetcode-1161: Maximum in-layer element sum
- vlan间路由+静态路由+NAT(PAT+静态NAT)综合实验
- [1153]mysql中between的边界范围
猜你喜欢
Observer mode (1)
力扣刷题之有效的正方形(每日一题7/29)
完整复制虚拟机原理(云计算)
Real-time image acquisition based on FPGA
用户交互+格式化输出
mmdetection训练一个模型相关命令
Drools基本介绍,入门案例,基本语法
SQL注入 Less54(限制次数的SQL注入+union注入)
SQL注入 Less46(order by后的注入+rand()布尔盲注)
The comprehensive result of the case statement, do you know it?[Verilog Advanced Tutorial]
随机推荐
The effective square of the test (one question of the day 7/29)
Drools规则属性,高级语法
AtCoder Beginner Contest 261 Partial Solution
Coldfusion file read holes (CVE - 2010-2861)
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
Go 项目实战-获取多级分类下的全部商品
How to do a startup CTO?
19.支持向量机-优化目标和大间距直观理解
The principle of complete replication of virtual machines (cloud computing)
Fiddler captures packets to simulate weak network environment testing
The real CTO is a technical person who understands products
multiplayer-hlap 包有问题,无法升级的解决方案
CorelDRAW2022精简亚太新增功能详细介绍
拒绝加班,程序员开发的效率工具集
Verify the integer input
Classic linked list OJ strong training problem - fast and slow double pointer efficient solution
vlan间路由+静态路由+NAT(PAT+静态NAT)综合实验
Nacos
STM32CUBEMX develops GD32F303 (11) ---- ADC scans multiple channels in DMA mode
Refuse to work overtime, a productivity tool set developed by programmers