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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rework-font-names

v0.1.1

Published

Plugin for rework font names in CSS

Downloads

2

Readme

Rework Font Names in CSS

Font names plugin for Rework

Allows for CSS to modify font-names in 'font' and 'font-family' rules

Options

Pass in an options object to configure the plugin. Possible options:

  • replace: replaces old value by new one (can be a string, array or function)
  • prepend: prepends new font(s) to font list (can be a string, array or function)
  • append: appends font(s) to font list (can be a string, array or function)
  • ignore: if rule has in font stack at least one font from ignore list, replace/prepend/append options can't be applied to this rule. Can be a string, array or function. You can also add '!important' and 'inherit' as option values, and all fonts stacks with '!important' or 'inherit' will be ignored. Default value forn ignore option is ['inherit']
  • important: how to rework !important; possible values:
    • keep: default value, keeps !important where they are
    • add: adds !important for all acceptable font stacks (i.e. all ones except ignored ones)
    • remove: removes !important from all acceptable font stacks (i.e. all ones except ignored ones)

Functions for replace, prepend and apppend options can have four params:

  • value: raw value of font-family or font property
  • fonts: a normalized list of fonts
  • important: true if font-stack has !important; false if font-stack doesn't have !important

Example

The following gulp snippet

var rework = require('gulp-rework');
rework.fontNames = require('rework-font-names');

return gulp.src('app/styles/main.css')
    .pipe(rework(rework.fontNames({
        replace: function(v,f,i){ return v.replace(/Ariel/gi, 'Arial');  },
        prepend: ["PT Sans", 'Helvetica Neue'],
        append: 'sans-serif',
        ignore: ['Courier New', '!important', 'inherit'],
    })))
    .pipe(gulp.dest('dist/css'))

Will turn

html {
  font: bold 16px/1.4em Ariel, "Helvetica";
}

body {
  font-family: Ariel; 
}

#wrapper {
  font: 'courier new';
}

.button {
  font-family: Tahoma !important;
}

Into

html {
  font: bold 16px/1.4em "PT Sans", "Helvetica Neue", Arial, "Helvetica", sans-serif;
}

body {
  font-family: "PT Sans", "Helvetica Neue", Arial, sans-serif; 
}

#wrapper {
  font: 'courier new';
}

.button {
  font-family: Tahoma !important
}