Skip to content

hsiaosiyuan0/fonts

Repository files navigation

font-toolkit

Font file manipulating in typescript.

demo

Install

npm install font-toolkit

Usage

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);

About

Slicing and converting fonts in typescript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published