Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hsiaosiyuan0/fonts
Slicing and converting fonts in typescript.
https://github.com/hsiaosiyuan0/fonts
Last synced: 3 months ago
JSON representation
Slicing and converting fonts in typescript.
- Host: GitHub
- URL: https://github.com/hsiaosiyuan0/fonts
- Owner: hsiaosiyuan0
- License: mit
- Created: 2018-04-04T08:56:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T19:52:24.000Z (almost 2 years ago)
- Last Synced: 2024-07-08T15:59:27.920Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 15.3 MB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-typography - font-toolkit - Font file manipulating in TypeScript. (JavaScript)
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);
```