Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oldj/node-font-list
Get the list of fonts installed in the system.
https://github.com/oldj/node-font-list
electron font nodejs
Last synced: 3 months ago
JSON representation
Get the list of fonts installed in the system.
- Host: GitHub
- URL: https://github.com/oldj/node-font-list
- Owner: oldj
- License: mit
- Created: 2017-02-06T02:57:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-28T03:21:54.000Z (about 1 year ago)
- Last Synced: 2024-07-18T17:15:08.518Z (4 months ago)
- Topics: electron, font, nodejs
- Language: JavaScript
- Homepage:
- Size: 57.6 KB
- Stars: 127
- Watchers: 3
- Forks: 22
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs-pure-js - font-list
README
# 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
```bash
npm install font-list
```## Usage
```js
const fontList = require('font-list')fontList.getFonts()
.then(fonts => {
console.log(fonts)
})
.catch(err => {
console.log(err)
})
```or like this in TypeScript:
```ts
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`:```js
const fontList = require('font-list')fontList.getFonts({ disableQuoting: true })
.then(fonts => {
console.log(fonts)
})
.catch(err => {
console.log(err)
})
```