Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hsiaosiyuan0/fonts

Slicing and converting fonts in typescript.
https://github.com/hsiaosiyuan0/fonts

Last synced: 28 days ago
JSON representation

Slicing and converting fonts in typescript.

Awesome Lists containing this project

README

        

# font-toolkit

Font file manipulating in typescript.

[demo](http://fonts.thehardways.me/)

## Install

```bash
npm install font-toolkit
```

## Usage

```js
const util = require("util");
const fontKit = require("font-toolkit");

const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);

// read font
const buf = await readFile("path-to-your-font");
const srcFont = new fontKit.Font(buf);
srcFont.satisfy();

// minify
const mini = new fontKit.Minifier(srcFont);
const newFont = mini.with("永和九年,岁在癸丑");

// write to buf
const wb = new fontKit.BufferWriter();
newFont.write2(wb);

await writeFile("path-to-your-dist", wb.buffer);
```