
Detect which font your system has cherry-picked from font-family.
- npm:
npm install detect-font --save
Usage
; const element = document; // Yield the first font that is supported on the element.console; // Otherwise display all valid fonts for the element.console;
When a typeface is encountered — monospace
, sans-serif
or serif
— then it will be returned and the font discovery will not continue. For example in the following case monospace
will be returned — the fonts will not be considered:
In the unlikely event that a valid font cannot be determined detectFont
will yield false
— an empty array will be returned by supportedFonts
.
Found a problem? Please raise an issue.