0.3.3 • Published 4 years ago

fontscan v0.3.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

fontscan

Test

Get font list in specified directory(default system fonts).

This project respect font-manager.

cf.

fontscanfont-manager
nativeNo, only JSYes, made with C
custom directoriesYes, you canNo, only system fonts
accuracyNot goodGood
speedSlowFast

more info...

Usage

Get system fonts.

const fontscan = require('fontscan');
console.log(await fontscan.getFontList());

// output
[
  FontDescriptor {
    path: 'C:\\Windows\\Fonts\\AGENCYB.TTF',
    postscriptName: 'AgencyFB-Bold',
    family: 'Agency FB',
    monospace: false,
    width: 3,
    weight: 700,
    italic: false,
    style: 'Bold'
  },
  FontDescriptor {
    path: 'C:\\Windows\\Fonts\\AGENCYR.TTF',
    postscriptName: 'AgencyFB-Reg',
    family: 'Agency FB',
    monospace: false,
    width: 3,
    weight: 400,
    italic: false,
    style: 'Regular'
  },
  ... more items ]

Fonts in specified directory.

Note: We recommend that you do not specify the root directory, as custom directories are searched recursively.

const fonts = await fontscan.getDirectoryFonts('/Library/Fonts');
const fonts = await fontscan.getDirectoriesFonts([
  `C:\\Users\\${username}\\Fonts`,
  `D:\\Fonts`
]);

API

fontscan

fontscan.getFontList(options?): Promise<FontDescriptor[]>

Get fontdescriptors that installed and in specified directories.

  • options
    • customDirectories
      • string[]
      • default: []
    • onlyCustomDirectories
      • boolean
      • default: false

fontscan.getDescriptorFromPaths(fontPaths): Promise<FontDescriptor[]>

Get fontdescriptors that specified files.

  • fontPaths
    • string[]

fontscan.getDirectoryFonts(dirPath): Promise<FontDescriptor[]>

Get fontdescriptors that in specified directory.

  • dirPath
    • string

fontscan.getDirectoriesFonts(dirPaths): Promise<FontDescriptor[]>

Get fontdescriptors that in specified directories.

  • dirPaths
    • string[]

fontscan.getInstalledFonts(): Promise<FontDescriptor[]>

Get fontdescriptors that installed.

FontDescriptor

Font descriptor has basic font informations.

Properties

  • path: string
  • family: string
  • postscriptName: string
  • width: number
  • weight: number
  • style: string
    • e.g. Regular, Bold, Italic, Bold italic
  • italic: boolean
  • monospace: boolean

Contribution

  1. Fork
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the npm test command and confirm that it passes
  6. Create new Pull Request

Please tell me if my English is wrong

LICENSE

MIT

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.3

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago