You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8 KiB

4 years ago
  1. # postcss-minify-font-values [![Build Status][ci-img]][ci]
  2. > Minify font declarations with PostCSS.
  3. This module will try to minimise the `font-family`, `font-weight` and `font` shorthand
  4. properties; it can unquote font families where necessary, detect & remove
  5. duplicates, and cut short a declaration after it finds a keyword. For more
  6. examples, see the [tests](test).
  7. ```css
  8. h1 {
  9. font:bold 2.2rem/.9 "Open Sans Condensed", sans-serif;
  10. }
  11. p {
  12. font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
  13. font-weight: normal;
  14. }
  15. ```
  16. ```css
  17. h1 {
  18. font:700 2.2rem/.9 Open Sans Condensed,sans-serif
  19. }
  20. p {
  21. font-family: Helvetica Neue,Arial,sans-serif;
  22. font-weight: 400;
  23. }
  24. ```
  25. ## API
  26. ### minifyFontValues([options])
  27. #### options
  28. ##### removeAfterKeyword
  29. Type: `boolean`
  30. Default: `false`
  31. Pass `true` to remove font families after the module encounters a font keyword,
  32. for example `sans-serif`.
  33. ##### removeDuplicates
  34. Type: `boolean`
  35. Default: `true`
  36. Pass `false` to disable the module from removing duplicated font families.
  37. ##### removeQuotes
  38. Type: `boolean`
  39. Default: `true`
  40. Pass `false` to disable the module from removing quotes from font families.
  41. Note that oftentimes, this is a *safe optimisation* & is done safely. For more
  42. details, see [Mathias Bynens' article][mathias].
  43. ## Usage
  44. ```js
  45. postcss([ require('postcss-minify-font-values') ])
  46. ```
  47. See [PostCSS] docs for examples for your environment.
  48. ## Contributors
  49. See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
  50. # License
  51. MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
  52. [mathias]: https://mathiasbynens.be/notes/unquoted-font-family
  53. [PostCSS]: https://github.com/postcss/postcss
  54. [ci-img]: https://travis-ci.org/cssnano/postcss-minify-font-values.svg
  55. [ci]: https://travis-ci.org/cssnano/postcss-minify-font-values