0.1.5 • Published 8 months ago

unifont v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
8 months ago

unifont

npm version npm downloads Github Actions Codecov

Framework agnostic tools for accessing data from font CDNs and providers

Usage

Install package:

# npm
npm install unifont
import { createUnifont, providers } from 'unifont'

const unifont = await createUnifont([
  providers.google(),
])

const fonts = await unifont.resolveFont('Poppins')

console.log(fonts)

In most environments, you will want to cache the results of font APIs to avoid unnecessary hits to them. By default unifont caches font data in memory.

For full control, unifont exposes a storage API which is compatible with unstorage. It simply needs to expose a getItem and setItem method.

import { createUnifont, providers } from 'unifont'

import { createStorage } from 'unstorage'
import fsDriver from 'unstorage/drivers/fs-lite'

const storage = createStorage({
  driver: fsDriver({ base: 'node_modules/.cache/unifont' }),
})

const cachedUnifont = await createUnifont([providers.google()], { storage })

console.log(await cachedUnifont.resolveFont('Poppins'))

// cached data is stored in `node_modules/.cache/unifont`

For more about the storage drivers exposed from unstorage, check out https://unstorage.unjs.io.

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with ❤️

Published under MIT License.

0.1.5

8 months ago

0.1.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.0.2

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.0.0

1 year ago

1.0.0

6 years ago

0.0.1

6 years ago