package
fonts (ttf, woff, woff2, eot, svg, otf) parse, write, transform, glyph adjust.
npm install fonteditor-coreGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
FontEditor core functions
Read and write sfnt font like ttf, woff, woff2, eot, svg, otf.
// read font file
import {createFont} from 'fonteditor-core';
import fs from 'fs';
const buffer = fs.readFileSync('font.ttf');
// read font data, support format:
// - for ttf, otf, woff, woff2, support ArrayBuffer, Buffer
// - for svg, support string or Document(parsed svg)
const font = createFont(buffer, {
// support ttf, woff, woff2, eot, otf, svg
type: 'ttf',
// only read `a`, `b` glyphs
subset: [65, 66],
// read font hinting tables, default false
hinting: true,
// read font kerning tables, default false
kerning: true,
// transform ttf compound glyph to simple
This library supports both CommonJS and ES Modules. For detailed information on using with modern bundlers, please see ESM_USAGE.md.
// ESM import
import fonteditorCore, { createFont, woff2 } from 'fonteditor-core';
createFont(buffer, options);Notice: woff2 use wasm build of google woff2, before read and write woff2, we should first call woff2.init().
import {createFont, woff2} from 'fonteditor-core';
// in nodejs
woff2.init().then(() => {
// read woff2
const font = createFont(buffer, {
type: 'woff2'
});
// write woff2
const buffer = font.write({type: 'woff2'});
});
// in browser
woff2.init('/assets/woff2.wasm').then(() => {
// read woff2
const font = createFont();
// write woff2
const arrayBuffer
npm run devnpm run buildnpm run testNode.js:>= 12.0
Browser: Chrome, Safari
MIT © Fonteditor
kekee000
kekee000@gmail.com
Estimated unpacked size across 2 packages.
2.0 MB
Includes dependencies.