GithubHelp home page GithubHelp logo

bothyan / fonts-streamline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qdsang/fonts-streamline

0.0 2.0 0.0 213 KB

根据指定的文字重组字体库。其实就是精简字体库,让页面中轻松挂载任意字体,不必考虑字体文件大小。

License: MIT License

JavaScript 81.33% HTML 18.67%

fonts-streamline's Introduction

更好的项目: https://github.com/aui/font-spider

fonts-streamline

Join the chat at https://gitter.im/qdsang/fonts-streamline

根据指定的文字重组字体库。其实就是精简字体库,让页面中轻松挂载任意字体,不必考虑字体文件大小。

现在只支持SVG格式字体生成svg、ttf、woff、eot格式字体。如果是其他格式字体文件,在使用前必要先转换成svg格式字体,转换方法拖到下面去找。

使用方法

fonts-streamline 文本 svg字体文件路径 输出字体文件路径

eg:
fonts-streamline "一块钢板的艺术之旅40道工艺制程" ./FZLTCXHJW.svg ./iconfont.svg

或者

var fonts_streamline = require('fonts-streamline')
  , fs = require('fs');

fonts_streamline({
  keyword: '今天酱油了么?',
  fontFilePath: '/home/Users/dev/test.svg',
  fontName: 'qdsang'
}, function(fonts){

  fs.writeFileSync('./fonts.svg', fonts.svg);
  fs.writeFileSync('./fonts.woff', fonts.woff);
  fs.writeFileSync('./fonts.ttf', fonts.ttf);
  fs.writeFileSync('./fonts.eot', fonts.eot);

  console.log('ok');
});

关于字体文件格式转换成SVG格式

安装必要组件

OS X

brew install ttfautohint fontforge --with-python

You may need to use sudo for brew, depending on your setup.

Linux

sudo apt-get install fontforge ttfautohint

Windows

npm install grunt-webfont --save-dev

Then install ttfautohint (optional).

Only node engine available (see below).

参考

https://github.com/sapegin/grunt-webfont

开始转换

参考脚本 convert2svgfont.pe, 这是在mac系统下的例子,如果你写好了其他的例子,麻烦帮忙push下。

eg: ./convert2svgfont.pe ./FZLTCXHJW.TTF

提取网页字符

var html = document.body.innerHTML;
var words = html.replace(/[^\u4E00-\u9FA5]/g,'');
words += '1234567890qwertyuiopasdfghjklzxcvbnm,.QWERTYUIOPASDFGHJKLZXCVBNM';
console.log(words);

Stats

NPM NPM

参考项目

fonts-streamline's People

Contributors

qdsang avatar gitter-badger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.