Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

font-finder

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

font-finder

Quickly find system font names and metadata without native dependencies

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
decreased by-27.57%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 26 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc