Skip to content

🖋 Native bindings to `fonttools` to decompile and compile fonts.

Notifications You must be signed in to change notification settings

lucasbraum/node-fonttools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-fonttools

Native bindings to fonttools to decompile and compile fonts.

How It Works

fonttools (also known as TTX) is a library for manipulating fonts, written in Python. It supports TrueType, OpenType, AFM and to an extent Type 1, and some Mac-specific formats. Using Addons it's possible to bridge Python to Node, natively, using C++ and Python's Python/C API—which is exactly what node-fontools does.

Current Status

So far, the only functions that have been bridged are the abilities to decompile fonts to XML and compile XML to font binary.

Requirements

Python 2.7 is the only supported version at the moment.

How To Use

import fonttools from 'fonttools';
import { readFileSync } from 'fs';

// Get the `decompile` and `compile` methods
const { decompile, compile } = fonttools();

// Read a font file as a buffer
const fontBuffer = readFileSync('font.ttf');

// Decompile the font to another buffer
const fontXMLBuffer = decompile(fontBuffer);

// Insert logic here to manipulate font

// Compile font from an XML file as a buffer
const fontBinaryBuffer = compile(fontXMLBuffer);

// Insert logic to save font file buffer here

fonttools

A function that takes a path to fonttools/Lib and returns an object with two methods: decompile and compile. By default it uses the included submodule.

decompile

Takes a font file buffer and returns another buffer with the XML of the decompiled font.

compile

Takes an XML file buffer and returns another buffer with the compiled font file binary.

More on Node Buffers

About

🖋 Native bindings to `fonttools` to decompile and compile fonts.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 46.5%
  • JavaScript 39.7%
  • Python 13.8%