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 🙏

© 2024 – Pkg Stats / Ryan Hefner

font-finder

v1.1.0

Published

Quickly find system font names and metadata without native dependencies

Downloads

18,802

Readme

font-finder

Travis CI build status codecov npm version

Quickly find system font names and metadata without native dependencies.

npm install font-finder

Usage

const fontFinder = require('font-finder');

(async () => {
  console.log(await fontFinder.list());
  // {
  //   Calibri: [
  //     {
  //       path: 'C:/WINDOWS/Fonts/calibri.ttf',
  //       type: 'sansSerif',
  //       weight: 400,
  //       style: 'regular'
  //     },
  //     {
  //       path: 'C:/WINDOWS/Fonts/calibrii.ttf',
  //       type: 'sansSerif',
  //       weight: 400,
  //       style: 'italic'
  //     },
  //     ...
  //   ],
  //   'Courier New': [
  //     {
  //       path: 'C:/WINDOWS/Fonts/courbi.ttf',
  //       type: 'monospace',
  //       weight: 700,
  //       style: 'boldItalic'
  //     },
  //     ...
  //   ],
  //   ...
  // }

  console.log(await fontFinder.listVariants('Calibri'));
  // [
  //   {
  //     path: 'C:/WINDOWS/Fonts/calibri.ttf',
  //     type: 'sansSerif',
  //     weight: 400,
  //     style: 'regular'
  //   },
  //   {
  //     path: 'C:/WINDOWS/Fonts/calibrii.ttf',
  //     type: 'sansSerif',
  //     weight: 400,
  //     style: 'italic'
  //   },
  //   ...
  // ]

  console.log(await fontFinder.get('C:/WINDOWS/Fonts/calibri.ttf'));
  // {
  //   name: 'Calibri',
  //   path: 'C:/WINDOWS/Fonts/calibri.ttf',
  //   type: 'sansSerif',
  //   weight: 400,
  //   style: 'regular'
  // }

})();

API

list([options])

Lists all fonts present on the system, grouped by font name. Currently limited to ttf and otf fonts. Returns an object where the keys are the font family names and the values are arrays of metadata for each font variant.

Params

  • options [object] - Options for configuring font retrieval
    • language [string] - The language to use when fetching font naming information. Default: 'en'
    • concurrency [string[]] - Maximum number of fonts to process concurently. You can tweak this to get the maximum performance out of the call. Default: 4

listVariants(name, [options])

Lists all variants found for the provided font family. The format of each variant is the same as for each variant in the list() call. If no variants are found, an empty array is returned.

Params

  • name [string] - The font family name to search for
  • options [object] - Same as for list()

get(path, [options])

Gets metadata for a single font file, returning metadata for the first font variant found in the file. If there is an error extracting the font, an error is thrown (unlike in list, where the font is simply ignored). Returns data for a single font variant. The format is the same as for a single variant in list() and listVariants(), but also includes the font's name.

  • path [string] - Absolute path to the font file to parse
  • options [object] - Options for configuring font retrieval
    • language [string] - The language to use when fetching font naming information. Default: 'en'

Contributing

Want to contribute to the project? Go check out the Contribution Guide for instructions to set up your development environment, open an issue and create a pull request.