@mapka/font-sdf
v0.5.0
Published
Creates signed distance fields out of OpenType/TrueType fonts
Readme
@mapka/font-sdf
Generates Signed Distance Field glyphsets from OpenType fonts. Generated glyphs are stored in protobuf.
This is fork of fontnik with some changes.
Install
npm install @mapka/font-sdf
or
yarn add @mapka/font-sdfUsage
import {
fontToGlyphs,
readFont.
decode
} from "@mapka/glyph-pbf";
// Read a font saved as a PBF and decode it.
const sdf = readFileSync("fonts/OpenSans-Regular.pbf");
const pbf = decode(sdf);
// Read a font and generate glyphs for the range 0-255.
const font = readFont("fonts/OpenSans-Regular.ttf");
const buffer = fontToGlyphs(font, 0, 255);