1.0.2 • Published 1 year ago

@xfuturum/is-font-installed v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@xfuturum/is-font-installed

This package lets you check if a user has a given font installed (as if it was not clear from the name). A very scientific approach of rendering a string with a given font and comparing its width to a fallback is used. We assume you have Arial and Comic Sans MS installed.

Install it with npm i @xfuturum/is-font-installed or yarn add @xfuturum/is-font-installed.

How to use:

import isFontInstalled from '@xfuturum/is-font-installed';

window.addEventListener('DOMContentLoaded',function () {
    console.log(isFontInstalled("Arial")); // outputs true
});

You can also check for the Cyrillic or Latin extended version of the font installed:

import { default as isFontInstalled, isFontInstalledCyrillic, isFontInstalledExtLat } from '@xfuturum/is-font-installed';

window.addEventListener('DOMContentLoaded',function () {
    console.log(isFontInstalled("Papyrus")); // outputs true
    console.log(isFontInstalledCyrillic("Papyrus")); // outputs false
});
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago