Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-font-family

ben-eb28.2kMITdeprecated2.0.0

This module has been superceded by postcss-minify-font-values.

Normalize font family declarations with PostCSS.

css, font, normalize, optimise, optimisation, postcss, postcss-plugin

readme

postcss-font-family Build Status NPM version Dependency Status

Normalize font family declarations with PostCSS.

Install

With npm do:

npm install postcss-font-family --save

Example

This module will try to minimise the font-family and font shorthand properties; it can unquote font families where necessary, detect & remove duplicates, and cut short a declaration after it finds a keyword. For more examples, see the tests.

Input

h1 {
    font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
}

Output

h1 {
    font-family: Helvetica Neue,Arial,sans-serif;
}

API

fontFamily([options])

options

removeAfterKeyword

Type: boolean Default: true

Pass false to disable the module from removing font families after it encounters a font keyword, for example sans-serif.

removeDuplicates

Type: boolean Default: true

Pass false to disable the module from removing duplicated font families.

removeQuotes

Type: boolean Default: true

Pass false to disable the module from removing quotes from font families. Note that oftentimes, this is a safe optimisation & is done safely. For more details, see Mathias Bynens' article.

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

changelog

2.0.0

  • Upgraded to PostCSS 5.

1.2.1

  • Fixes an issue where rem measurements were being quoted alongside the font family name.

1.2.0

  • Adds support for a configuration object; some optimisations can be disabled.

1.1.1

  • Fixes an issue where 'Din' was being picked up by the logic as a numeric value, causing the full font name to be incorrectly rearranged.
  • Plugin guidelines compatibility.

1.1.0

  • Now uses the PostCSS 4.1 plugin API.

1.0.2

  • Adds a JSHint config, code tidied up.

1.0.1

  • Bug fix; now properly identifies unit-less values.

1.0.0

  • Initial release.