Skip to content
forked from photopea/Typr.js

Typr.ts - TypeScript class wrapper for photopea/Typr.js

License

Notifications You must be signed in to change notification settings

fredli74/Typr.ts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typr.ts

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 constructor new typr.Font(buffer)
  • Typr.U functions are members of the class font.codeToGlyph(code)

Installation

npm install @fredli74/typr --save-dev

node load example

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));

About

Typr.ts - TypeScript class wrapper for photopea/Typr.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 89.4%
  • TypeScript 10.6%