zoukankan      html  css  js  c++  java
  • grunt插件[fontspider] : 转码,压缩字体 @fontface

    字蛛插件:压缩与转码静态页面中的 WebFont 

    需要注意的是,目前只支持 grunt@0.4.1

    package.json
    
    {
      "name": "fontS",
      "version": "1.0.0",
      "devDependencies": {
        "grunt": "^0.4.1",
        "grunt-contrib-copy": "^1.0.0",
        "grunt-font-spider": "^0.1.5"
      }
    }

    复制package.json

    运行npm install  自动安装插件

    Gruntfile.js

    module.exports = function(grunt) { grunt.initConfig({ // 拷贝文件到发布目录,这样字体可被反复处理 copy: { main: { src: './src/**', dest: './dest/' }, }, // 字蛛插件:压缩与转码静态页面中的 WebFont 'font-spider': { options: {}, main: { src: './dest/**/*.html' } } }); grunt.loadNpmTasks('grunt-font-spider'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.registerTask('default', ['copy', 'font-spider']); };

    html/css中需要写好@font-face ,  ttf文件必须存在

        @font-face {
            font-family: 'pinghei';
            src: url('../font/pinghei.eot');
            src: url('../font/pinghei.eot?#font-spider') format('embedded-opentype'), 
            url('../font/pinghei.woff') format('woff'), 
            url('../font/pinghei.ttf') format('truetype'), 
            url('../font/pinghei.svg') format('svg');
            font-weight: normal;
            font-style: normal;
        }

    font-spider,只会提取html中应用@font-face 字体的文字,

    生成相应的ttf,woff,svg,eot四种字体格式

  • 相关阅读:
    FZOJ2115+月赛+多项式
    Statistical Data Mining Tutorials [转]
    码农何去何从
    关于InnoDB索引长度限制的tips
    虚拟化、云计算、开放源代码及其他
    互联网开放平台应用综述
    2012.09月面试五十题
    linux运维常用命令
    Linux 性能测试与分析转
    "Principles of Computer Systems Design"
  • 原文地址:https://www.cnblogs.com/king2016/p/5980828.html
Copyright © 2011-2022 走看看