npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

benfont

v1.1.0

Published

根据页面,提取并生成字体

Readme

benFont

基于fontmin可以针对不同的项目,字体生成使用

特点

  • 支持同个页面使用多个字体
  • 支持选择器,过滤生成特定字体

安装

在package.json中,添加benfont

npm install

引入

var benfont = require('benfont');
benfont.watch('../product/**/*.tpl', '../font/');
  • 例如上面例子,是针对../product/下面的任意tpl文件,不限层级
  • ../font/ 表示存放字体文件的文件夹,即源文件夹,可以自行百度字体ttf文件下载
  • tpl文件一旦修改,会在同等目录下生成一个font文件夹,里面放置所有需要的字体文件

使用

  • 还需要在tpl文件头部声明,使用字体,及class选择器名称,例如
  • 在模板中,添加下面的标记后,就能在模板对应的路径,生成font文件夹,放置字体文件
<input type="hidden" class='J_benfont' data-class='ben-font' value='syNormal'>
  • data-class为选择器名称,可以自定义,即需要提取的字的容器的class
  • value为字体名称,可以自行更改,但必须与,字体文件夹里面的字体名字保持一致(去掉.ttf后的名字)
  • class不能修改。
  • scss文件中声明
@mixin fontBlock($name, $fontName) {
    font-family: $fontName;
    src: url("./font/" + $name + "_" + $fontName + ".eot");
    src:
    url("./font/" + $name + "_" + $fontName + ".eot?#font-spider") format('embedded-opentype'),
    url("./font/" + $name + "_" + $fontName + ".woff") format('woff'),
    url("./font/" + $name + "_" + $fontName + ".ttf") format('truetype'),
    url("./font/" + $name + "_" + $fontName + ".svg") format('svg');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    @include fontBlock('index', 'DINOffcPro-Cond');
}
.ben-font{
    font-family: 'DINOffcPro-CondBold';
}
  • $name 表示模板的名字,字体文件跟着模板生成的,所以需要传入模板的名字
  • $fontName 表示ttf文件夹里面的字体名字。然后声明font-family的时候也要保持一致

谢谢浏览ヾ(。´・_●・`。)☆