TypeScript class wrapper for photopea/Typr.js.
Design goal was to keep the core Typr.js fork in a separate branch as close to the original as possible to make eventual merging easier.
As of May 2020, the official photopea Typr.js project switched to using HarfBuzz and threw a lot of the font format parsing out. For that reason, my fork will have to continue it's own path.
I use this library in one of my own TypeScript projects and have only added class features that I needed.
Typr.parse(buffer)
is done through the class constructornew typr.Font(buffer)
Typr.U
functions are members of the classfont.codeToGlyph(code)
npm install @fredli74/typr --save-dev
import * as fs from "fs";
import * as typr from '@fredli74/typr';
function toArrayBuffer(buf: Buffer) {
let ab = new ArrayBuffer(buf.length);
let view = new Uint8Array(ab);
for (let i = 0; i < buf.length; ++i) {
view[i] = buf[i];
}
return ab;
}
const data = fs.readFileSync("filename.ttf");
const font = new typr.Font(toArrayBuffer(data));