Modifying font files with JavaScript

This script loads a TrueType/OpenType font file through AJAX and parses all the contents from binary to human readable values and maps them in objects for better organization. Once the whole file has been parsed, the values in the objects can be freely modified to alter anything in the font file. Once all the modifications are done, the script compiles the font back into an ArrayBuffer, from which it can be either be outputted as base64 encoded or as a blob URI, which can be embedded for example in CSS.

Currently there are no helper methods available yet to for example visualize the glyph instructions, which compose a single character in a font, which would assist in creating a WYSIWYG editor for font glyphs. Currently working on implementing helper functions to add, move and remove glyphs.

Font files consist of a number of required tables and some optional tables. For some examples of what kind of data is within the tables, have a look at the dump tables for ConsolaMono (0.25 mb), as well as its cmap & glyf (7.4 mb) tables.

The script currently requires DataView among other things (BlobBuilder, blob URL's, ArrayBuffers), meaning it currently only supports newer versions of Chrome.

Example
View example font parsing/building (Chrome only)