• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Get the list of fonts installed in the system.

font-list

font-list is a Node.js package for listing the fonts available on your system.

Current version supports MacOS, Windows, and Linux.

Install

npm install font-list

Usage

const fontList = require('font-list')

fontList.getFonts()
  .then(fonts => {
    console.log(fonts)
  })
  .catch(err => {
    console.log(err)
  })

or like this in TypeScript:

import { getFonts } from 'font-list'

getFonts()
  .then(fonts => {
    console.log(fonts)
  })
  .catch(err => {
    console.log(err)
  })

The return value fonts is an Array, looks like:

[ '"Adobe Arabic"',
  '"Adobe Caslon Pro"',
  '"Adobe Devanagari"',
  '"Adobe Fan Heiti Std"',
  '"Adobe Fangsong Std"',
  'Arial',
  ...
  ]

If the font name contains spaces, the name will be wrapped in double quotes, otherwise there will be no double quotes, for example: '"Adobe Arabic"', 'Arial'.

If you don't want font names that contains spaces to be wrapped in double quotes, pass the options object with disableQuoting set to true when calling the method getFonts:

const fontList = require('font-list')

fontList.getFonts({ disableQuoting: true })
  .then(fonts => {
    console.log(fonts)
  })
  .catch(err => {
    console.log(err)
  })