The svg2ttf function converts an SVG font string into a TTF byte buffer.
Signature:
svg2ttf(svgFontString, options) -> buf
Parameters:
svgFontString: The raw SVG font content as a string.options: An object to configure font metadata:copyright: (optional) Copyright string.description: (optional) Description string.ts: (optional) Unix timestamp (in seconds) to override the creation time.url: (optional) Manufacturer URL.version: (optional) Font version string (e.g., Version x.y or x.y).
Return Value:
Returns a buf object (an internal byte buffer similar to DataView). To get the actual TTF content, access the buffer property, which is a Uint8Array or Array.
var fs = require('fs');
var svg2ttf = require('svg2ttf');
// Convert SVG to TTF buffer
var ttf = svg2ttf(fs.readFileSync('myfont.svg', 'utf8'), {});
// Write the buffer content to a file
fs.writeFileSync('myfont.ttf', new Buffer(ttf.buffer));