Samsa-Core is the JavaScript library at the heart of Samsa. There are two fundamental classes: SamsaFont
and SamsaGlyph
, with properties and methods described below for parsing variable fonts (VFs), creating VF instances, converting glyph outlines to SVG, and exporting static TTFs.
These functions are used in the graphical tool Samsa-GUI, the command-line utility Samsa-CLI and the polyfill demo Samsa-Polyfill.
A SamsaFont can be initialised in any of the following ways:
//from a URL
let vf = new SamsaFont({
fontFamily: "FontNameShouldGoHere",
url: "fonts/Sans_Variable.ttf",
callback: function (font) {}
});
//from a font file upload
let vf = new SamsaFont({
arrayBuffer: e.target.result,
inFile: file.name,
filesize: file.size, //Optional
date: file.lastModified, //Optional
callback: function (font) {}
});