当前位置:网站首页>字体压缩神器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 -g2、检查有没有安装成功
font-spider -V3、打开你的目录,找到你的源文件在的文件夹,比如我的
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.html6、可以看到下面的界面,源文件2M,压缩以后是60k左右,还有其他格式可以用


7、美滋滋把,用起来,css引入:
@font-face {
font-family: 'LouisVuittonGlobal-Regular';
src: url("../fonts/LouisVuittonGlobal-Regular.ttf") format('truetype'); //主要是这句话
font-weight: normal;
font-style: normal;
}边栏推荐
- C language applet -- common classic practice questions
- To write good test cases, you must first learn test design
- CMOS和TTL的区别?
- mmdetection训练一个模型相关命令
- LeetCode 每日一题 2022/7/25-2022/7/31
- How to do a startup CTO?
- MPPT太阳能充放电控制器数据采集-通过网关采集电池电压容量电量SOC,wifi传输
- How to design the changing system requirements
- Problems that need to be solved by the tcp framework
- Unity界面总体介绍
猜你喜欢

全流程调度——MySQL与Sqoop

leetcode-1161: Maximum in-layer element sum

经典链表OJ强训题——快慢双指针高效解法

19.支持向量机-优化目标和大间距直观理解

Unity界面总体介绍

Introduction to flask series 】 【 flask - using SQLAlchemy

直播预告 | KDD2022博士论文奖冠亚军对话

Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things

221. Largest Square

The real CTO is a technical person who understands products
随机推荐
What have I experienced to become a tester who is harder than development?
[1154] How to convert string to datetime
静态路由+PAT+静态NAT(讲解+实验)
The difference between link and @import
coldfusion8 background scheduled tasks take shell
How to expose Prometheus metrics in go programs
基于FPGA的图像实时采集
print task sorting js od huawei
f.grid_sample
Android's webview cache related knowledge collection
Drools规则属性,高级语法
The modification is not properly placed in the sandbox, causing Apple compatibility issues
Difference between CMOS and TTL?
Can an inexperienced college graduate switch to software testing?my real case
1. Non-type template parameters 2. Specialization of templates 3. Explanation of inheritance
Installation, start and stop of redis7 under Linux
How to do a startup CTO?
AI中的数学思想
AI在医疗影像设备全流程应用
cudaMemcpy学习笔记