博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
网站优化之字体
阅读量:6953 次
发布时间:2019-06-27

本文共 2188 字,大约阅读时间需要 7 分钟。

首先,处理字体,在网页:https://www.fontsquirrel.com/tools/webfont-generator

目前,@ font-face的支持

  • Firefox
  • Opera
  • Chrome
  • Safari
  • Internet Explorer 9

在旧的浏览器使用@ font-face时,不同的浏览器支持特定的字体文件。

  • IE浏览器:EOT
  • Mozilla浏览器:OTF,TTF
  • Safari浏览器:OTF,TTF​​,SVG
  • 歌剧:OTF,TTF​​,SVG
  • Chrome浏览器:TTF,SVG

将其分别转成.eot  .woff  .ttf  .svg  ,然后利用@font-face

@font-face {
font-family:'fangZheng'; src:url('../fontface/fangZheng/_gbk_m-webfont.eot'); src:url('../fontface/fangZheng/_gbk_m-webfont.eot') format('embedded-opentype'), /* IE6-IE8 */url('//at.alicdn.com/t/font_1474877045_270467.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */url('../fontface/fangZheng/_gbk_m-webfont.woff') format('woff') /* chrome、firefox */,url('../fontface/fangZheng/_gbk_m-webfont.svg') format('svg'); } //使用的时候
.banner-text>p{font-family:'fangZheng';}

3,在页面中载入Web font系列的字体子集

下载:https://github.com/ecomfe/fontmin-app/releases 注意:字体支持:,,,所以不是太普遍的适用。
 

4,中文字体的自动化构建;

     基于  和 ,按需提取字型,多格式转换,自动化构建字体。

参考配置:http://efe.baidu.com/blog/chinese-font-build/
$ npm install -g edp

然后:

$ git clone https://github.com/junmer/edp-build-fontmin-demo    // 下载 示例项目$ cd edp-build-fontmin-demo                                     // 进入 示例项目 路径$ npm install edp-build-fontmin                                 // 安装 edp-build-fontmin 依赖$ edp build -f

 

5,gulp构建

参考配置:https://github.com/ecomfe/gulp-fontmin
$ npm install --save-dev gulp-fontmin

6.font-spider

Install

npm install font-spider -g

应用css:

@font-face {
font-family: 'source'; src: url('../font/source.eot'); src: url('../font/source.eot?#font-spider') format('embedded-opentype'), url('../font/source.woff2') format('woff2'), url('../font/source.woff') format('woff'), url('../font/source.ttf') format('truetype'), url('../font/source.svg') format('svg'); font-weight: normal; font-style: normal;}.home h1, .demo > .test {
font-family: 'source';}

下载:

https://github.com/aui/font-spider

拓展: -使用这样的服务,选择一个可备用的字体,以免字体未加载完或加载失败,而出现的空白。 -Font Face Observer, 压缩后大小4KB,这块也不熟https://github.com/bramstein/fontfaceobserver
-字体加载器——,这块还不熟。https://github.com/bramstein/fontloader
参考:http://www.w3cplus.com/css3/the-font-face-dilemma.html

转载于:https://www.cnblogs.com/wang715100018066/p/6001398.html

你可能感兴趣的文章
Linux终端的总结和shell
查看>>
Java8 十大新特性详解
查看>>
Maven学习总结(五)——聚合与继承
查看>>
Oracle AWR 阙值影响历史执行计划
查看>>
集成显卡连接显示器的线跟独立显卡的不同么,分别叫什么
查看>>
我的友情链接
查看>>
Java是传值还是传引用
查看>>
文件夹权限
查看>>
【翻译】Siesta事件记录器入门
查看>>
将Ext JS 5应用程序导入Web项目以及实现本地化
查看>>
HTML5开发手机项目—个人总结
查看>>
《完整部署 OCS-NG》
查看>>
codeforces 812B. Sagheer, the Hausmeister
查看>>
第24周SDAI缓解能否预测远期RA骨破坏受抑制
查看>>
Away3D 的实体收集器Bug
查看>>
对于新旧技术的争论,我很low的想法
查看>>
Zabbix2.4.X_监控SNMP
查看>>
VirtualBox是什么
查看>>
linux定时任务Crond之服务器同步时间05
查看>>
需求改进与系统设计
查看>>