Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ssssota/node-font-kit
Node bindings to font-kit(Rust crate)
https://github.com/ssssota/node-font-kit
font nodejs opentype rust
Last synced: about 2 months ago
JSON representation
Node bindings to font-kit(Rust crate)
- Host: GitHub
- URL: https://github.com/ssssota/node-font-kit
- Owner: ssssota
- License: apache-2.0
- Created: 2021-01-18T14:28:37.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-12T12:24:55.000Z (over 2 years ago)
- Last Synced: 2024-12-16T22:34:05.814Z (about 2 months ago)
- Topics: font, nodejs, opentype, rust
- Language: Rust
- Homepage: https://www.npmjs.com/package/node-font-kit
- Size: 5.6 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# node-font-kit
Node.js wrapper for [font-kit (Rust crate)](https://crates.io/crates/font-kit).
This library works like [font-manager](https://github.com/foliojs/font-manager/).
## Features
- Get the path of installed fonts
- Get the font info
- Full name (*Depends on platform.*)
- Family name
- Postscript name
- Italic(Oblique)?
- Weight
- Stretch
- Monospace?> You cannot get the correct properties with variable fonts.
> Check [this document](https://neon-bindings.com/docs/electron-apps) if you use this with Electron.
## Installation
```sh
npm install node-font-kit
```## Example
```js
const { getPathAll, getProps } = require('node-font-kit');// Get the path of installed fonts
getPathAll().then(list => {
list.forEach((path, i) => console.log(i, path));
});/*
0 C:\\WINDOWS\\FONTS\\ROBOTO-THIN.TTF
1 C:\\WINDOWS\\FONTS\\CANDARAB.TTF
2 C:\\WINDOWS\\FONTS\\COURBI.TTF
3 C:\\WINDOWS\\FONTS\\UBUNTU-LIGHT.TTF
4 C:\\WINDOWS\\FONTS\\PALA.TTF
5 C:\\WINDOWS\\FONTS\\COMIC.TTF
:
:
*/getProps('path/to/font.otf').then(props => {
props.forEach((prop) => console.log(prop));
});/*
{
fullname: 'Mplus 1p',
family: 'Mplus 1p',
postscriptName: 'Mplus1p-Regular',
monospace: false,
weight: 400,
strech: 1,
style: 'Normal'
}
*/
```## API
### `getPathAll() => Promise`
Returns a list of font paths as a Promise.
### `getProps(path: string) => Promise`
Returns a list of font properties as a Promise.
### `FontProperty`
```typescript
type FontProperty = {
fullname: string;
family: string;
postscriptName: string;
monospace: boolean;
weight: number;
strech: number;
style: 'Normal' | 'Italic' | 'Oblique';
};
```