JSPM

postcss-discard-font-face

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6325
  • Score
    100M100P100Q139913F
  • License MIT

Discard font faces by type, with PostCSS.

Package Exports

  • postcss-discard-font-face

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-discard-font-face) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-discard-font-face Build Status NPM version Dependency Status

Discard font faces by type, with PostCSS.

Install

With npm do:

npm install postcss-discard-font-face --save

Example

When discarding TTF fonts:

Input

@font-face {
    src: url("webfont.ttf") format("truetype"),
         url("webfont.svg#svgFontName") format("svg");
}

Output

@font-face {
    src: url("webfont.svg#svgFontName") format("svg");
}

API

discardFonts([filter])

filter

Type: function|array Return: boolean|string Arguments: The function is passed the URL of the font as the first argument, and the format as the second.

For each font, return false to remove, or a new string if you would like to transform the URL.

// Remove fonts of an unknown type

discardFonts(function (url, format) {
    if (~url.indexOf('.exe')) {
        return false;
    }
});

Alternately, you can whitelist an array of types:

discardFonts(['ttf', 'svg']);

With this setting, all extensions that do not match will be removed.

Usage

See the PostCSS documentation for examples for your environment.

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs