# loadfont

> A simple wrapper for FontFaceObserver library with more comfortable configuration for font-heavy web projects.

Latest version **0.1.1** (published 2017-01-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install loadfont
pnpm add loadfont
yarn add loadfont
bun add loadfont
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-01-30 |
| First published | 2017-01-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nick Bodnariuk |
| Maintainers | rezoh |
| Keywords | font, css, font-loading, fontfaceobserver |

## Links

- npm: https://www.npmjs.com/package/loadfont
- Repository: https://github.com/rezoh/loadFont
- Homepage: https://github.com/rezoh/loadFont#readme
- Issues: https://github.com/rezoh/loadFont/issues
- npm.io page: https://npm.io/package/loadfont

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-01-30

## README

# LoadFont

A simple wrapper for [FontFaceObserver](https://github.com/bramstein/fontfaceobserver) 
library with more comfortable configuration for font-heavy web projects.

_With ES6, Promises and love._

## How to use

#### Write some CSS
```css
/* A lot of @font-face declarations... */

/* Classes for a 'progressive' fonts loading */
.js-font-loaded {
    font-family: Lora, sans-serif;
}

.js-font-loaded--bold .bold {
    font-weight: 700;
}
```

#### Add FontFaceObserver and LoadFont on your page
```html
<script src="src/fontfaceobserver.js"></script>
<script src="src/loadFont.js"></script>
```

#### Write config
```javascript
loadFont
    .load([
        {
            name: "Lora",
            timeout: 2000,
            settings: {
                weight: 400,
                style: 'normal'
            },
            onload: function () {
                document.documentElement.classList.add('js-font-loaded')
            },
            next: {
                name: "Lora",
                timeout: 5000,
                settings: {
                    weight: 700,
                    style: 'normal'
                },
                onload: function () {
                    document.documentElement.classList.add('js-font-loaded--bold')
                }
            }
        }
    ])
    .then(function () {
        console.log('All fonts loaded.');
    });
```

---
_Source: https://npm.io/package/loadfont · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
