npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

font-list

v2.0.1

Published

list system fonts

Readme

font-list

A Node.js package for listing system fonts with support for both CommonJS and ES modules.

npm version License: MIT

Features

  • 🖥️ Cross-platform support: Works on macOS, Windows, and Linux
  • 📦 Dual module support: Compatible with both CommonJS and ES modules
  • 🔍 Two API methods: Basic font listing and detailed font information
  • 📝 TypeScript support: Includes TypeScript type definitions
  • Async/Promise based: Modern asynchronous API

Installation

npm install font-list

Quick Start

CommonJS

const { getFonts } = require('font-list')

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

ES Modules

import { getFonts } from 'font-list'

const fonts = await getFonts()
console.log(fonts)

TypeScript

import { getFonts, FontInfo } from 'font-list'

const fonts: string[] = await getFonts()
const detailedFonts: FontInfo[] = await getFonts2()

API Reference

getFonts(options?)

Returns a list of font family names available on the system.

Parameters:

  • options (optional): Configuration object
    • disableQuoting (boolean): If true, font names with spaces won't be wrapped in quotes. Default: false

Returns: Promise<string[]>

Example output:

[
  '"Adobe Arabic"',
  '"Adobe Caslon Pro"',
  'Arial',
  'Helvetica',
  ...
]

Usage examples:

// Default behavior (with quotes for names containing spaces)
const fonts = await getFonts()
// Result: ['"Adobe Arabic"', 'Arial', ...]

// Disable quoting
const fonts = await getFonts({ disableQuoting: true })
// Result: ['Adobe Arabic', 'Arial', ...]

getFonts2(options?)

Returns detailed font information including both family names and PostScript names.

Parameters:

  • options (optional): Same as getFonts()
    • disableQuoting (boolean): Default: false

Returns: Promise<FontInfo[]>

FontInfo interface:

interface FontInfo {
  name: string           // Original family name
  familyName: string     // Standardized family name
  postScriptName: string // PostScript name
  weight: string         // Font weight (ultralight, light, regular, medium, semibold, bold, heavy)
  style: string          // Font style (normal, italic, oblique)
  width: string          // Font width (condensed, normal, expanded)
  monospace: boolean     // Whether the font is monospaced
}

Example output:

[
  {
    name: 'Adobe Arabic',
    familyName: '"Adobe Arabic"',
    postScriptName: 'AdobeArabic-Regular',
    weight: 'regular',
    style: 'normal',
    width: 'normal',
    monospace: false
  },
  {
    name: 'Arial',
    familyName: 'Arial',
    postScriptName: 'ArialMT',
    weight: 'regular',
    style: 'normal',
    width: 'normal',
    monospace: false
  },
  {
    name: 'Courier New',
    familyName: '"Courier New"',
    postScriptName: 'CourierNewPSMT',
    weight: 'regular',
    style: 'normal',
    width: 'normal',
    monospace: true
  },
  ...
]

Usage examples:

// Get detailed font information
const detailedFonts = await getFonts2()
console.log(detailedFonts[0].familyName)     // "Adobe Arabic"
console.log(detailedFonts[0].postScriptName) // AdobeArabic-Regular
console.log(detailedFonts[0].weight)         // regular
console.log(detailedFonts[0].style)          // normal
console.log(detailedFonts[0].width)          // normal
console.log(detailedFonts[0].monospace)      // false

// With disabled quoting
const detailedFonts = await getFonts2({ disableQuoting: true })
console.log(detailedFonts[0].familyName)     // Adobe Arabic

// Filter monospace fonts
const monospaceFonts = detailedFonts.filter(font => font.monospace)
console.log(monospaceFonts.map(f => f.familyName))

// Filter bold fonts
const boldFonts = detailedFonts.filter(font => font.weight === 'bold')
console.log(boldFonts.map(f => f.familyName))

Platform Support

| Platform | Method | Implementation | |----------|--------|--------------| | macOS | system_profiler | Uses system font database | | Windows | PowerShell/VBS | Registry and system font queries | | Linux | fc-list | Fontconfig library |

Module Formats

This package supports both CommonJS and ES modules through dual package exports:

// CommonJS
const { getFonts, getFonts2 } = require('font-list')

// ES Modules
import { getFonts, getFonts2 } from 'font-list'

// Default export (ES Modules)
import fontList from 'font-list'
const fonts = await fontList.getFonts()

Error Handling

try {
  const fonts = await getFonts()
  console.log(`Found ${fonts.length} fonts`)
} catch (error) {
  console.error('Failed to get fonts:', error.message)
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © oldj

Repository

https://github.com/oldj/node-font-list