fonttools-linux
v1.0.8
Published
Native bindings to `fonttools` to decompile and compile fonts.
Downloads
13
Readme
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