- Notifications
You must be signed in to change notification settings - Fork6
Framework agnostic tools for accessing data from font CDNs and providers
License
NotificationsYou must be signed in to change notification settings
unjs/unifont
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Framework agnostic tools for accessing data from font CDNs and providers
Install package:
# npmnpm install unifont
import{createUnifont,providers}from'unifont'constunifont=awaitcreateUnifont([providers.google(),])constfonts=awaitunifont.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 defaultunifont
caches font data in memory.
For full control,unifont
exposes a storage API which is compatible withunstorage
. It simply needs to expose agetItem
andsetItem
method.
import{createUnifont,providers}from'unifont'import{createStorage}from'unstorage'importfsDriverfrom'unstorage/drivers/fs-lite'conststorage=createStorage({driver:fsDriver({base:'node_modules/.cache/unifont'}),})constcachedUnifont=awaitcreateUnifont([providers.google()],{ storage})console.log(awaitcachedUnifont.resolveFont('Poppins'))// cached data is stored in `node_modules/.cache/unifont`
For more about the storage drivers exposed fromunstorage
, check outhttps://unstorage.unjs.io.
- Clone this repository
- EnableCorepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
Made with ❤️
Published underMIT License.
About
Framework agnostic tools for accessing data from font CDNs and providers
Topics
Resources
License
Code of conduct
Stars
Watchers
Forks
Packages0
No packages published