JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 76
  • Score
    100M100P100Q69525F
  • License MIT

Detect which font your system has cherry-picked from font-family.

Package Exports

  • detect-font

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (detect-font) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Detect which font your system has cherry-picked from font-family.

Travis   npm   License MIT

  • npm: npm install detect-font --save

Usage

import { detectFont, supportedFonts } from 'detect-font';

const element = document.querySelector('...');

// Yield the first font that is supported on the element.
console.log(detectFont(element));

// Otherwise display all valid fonts for the element.
console.log(supportedFonts(element));

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:

.example {
    font-family: monospace, "Times New Roman", Arial;
}

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.

forthebadge