Skip to content
Slicing and converting fonts in typescript.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
test
.editorconfig
.gitignore
.prettierrc
LICENSE
README.md
gulpfile.ts
package.json
tsconfig.json
tsconfig.scripts.json
tslint.json
yarn.lock

README.md

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);
You can’t perform that action at this time.