55 lines
2.0 KiB
Markdown
55 lines
2.0 KiB
Markdown
# parse-css-font
|
|
|
|
[](https://www.npmjs.org/package/parse-css-font)
|
|
[](https://www.npmjs.org/package/parse-css-font)
|
|
[](https://travis-ci.org/jedmao/parse-css-font)
|
|
[](https://codecov.io/gh/jedmao/parse-css-font)
|
|
[](https://bundlephobia.com/result?p=parse-css-font)
|
|
[](https://bundlephobia.com/result?p=parse-css-font)
|
|
[](https://github.com/prettier/prettier)
|
|
[](https://twitter.com/sindresorhus/status/457989012528316416?ref_src=twsrc%5Etfw&ref_url=https%3A%2F%2Fwww.quora.com%2FWhat-does-the-unicorn-approved-shield-mean-in-GitHub)
|
|
|
|
[](https://nodei.co/npm/parse-css-font/)
|
|
|
|
Parses the CSS [font property](https://developer.mozilla.org/en-US/docs/Web/CSS/font#font-variant-css21).
|
|
|
|
## Installation
|
|
|
|
```
|
|
$ npm install parse-css-font [--save[-dev]]
|
|
```
|
|
|
|
## Usage
|
|
|
|
```js
|
|
const parseCSSFont = require('parse-css-font')
|
|
parseCSSFont('1rem "Roboto Condensed", sans-serif;')
|
|
/*
|
|
{
|
|
size: '1rem',
|
|
family: ['Roboto Condensed', 'sans-serif'],
|
|
style: 'normal',
|
|
variant: 'normal',
|
|
weight: 'normal',
|
|
stretch: 'normal',
|
|
lineHeight: 'normal'
|
|
}
|
|
*/
|
|
```
|
|
|
|
See [the tests](https://github.com/jedmao/parse-css-font/blob/master/src/index.test.ts) for more scenarios.
|
|
|
|
### ES6/2015 import
|
|
|
|
```ts
|
|
import parseCSSFont from 'parse-css-font'
|
|
```
|
|
|
|
## Testing
|
|
|
|
```
|
|
$ npm test
|
|
```
|
|
|
|
This will run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.
|