• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jacobp100/post-iconfonts: Converts an icon font to an SVG image

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

jacobp100/post-iconfonts

开源软件地址:

https://github.com/jacobp100/post-iconfonts

开源编程语言:

JavaScript 76.7%

开源软件介绍:

post-iconfonts

Converts an icon font to an SVG image

Online Version

npm install --save-dev post-iconfonts

TL;DR

Generate a SVG image with,

import postIconfonts from 'post-iconfonts';

const font = readFileSync('font-awesome.otf');
const css = readFileSync('font-awesome.css', 'utf-8');

const svgString = postIconfonts(css, font, { precision: 5 });

Then add icons with,

<svg width="12" height="12"><use xlink:href="/icons.svg#fa-check" /></svg>

API

postIconfonts(cssString, fontBuffer, options);

cssString must be a string. fontBuffer can be an ArrayBuffer or a standard node.js Buffer.

The options is an object that takes the following:

  • size (number, default 12) The height to make each glyph (shouldn't really affect anything)
  • width (number, default=size) The width of each glyph—effectively defines the aspect ratio
  • filterNames (array, optional) Export only these CSS class names from the icon font
  • transformNames (function, optional) Function must take a name and return a new name (can be used to remove fa-prefixes from icons)
  • precision (number, default 6) The number of decimal places for path data commands—decrease to lower the file size and quality
  • warnOnOversized (boolean, default false) when true, the return value will be { svg, oversizedGlyphs }, where svg is a string, and oversizedGlyphs is an array of glyphs that did not fit in the size/width boundary



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap