@lulliecat/svg2ttf
v6.0.6
Published
Converts SVG font to TTF font
Readme
svg2ttf
Converts SVG fonts to TTF format. Originally written for Fontello, this tool can be useful for various font conversion projects.
@lulliecat/svg2ttf is a security-updated fork of the original svg2ttf. The development environment has been modernized, and TypeScript type definitions will be provided in future releases.
For Developers
The internal API is similar to FontForge's API. Since the primary goal is generating icon fonts, some specific TTF/OTF features (such as kerning) may not be fully supported. However, the current codebase provides a solid foundation for development, saving you significant time in implementing correct TTF table writing and optimization.
Installation
Install globally via npm:
npm install -g @lulliecat/svg2ttfCLI Usage
Convert an SVG font to TTF format:
svg2ttf fontello.svg fontello.ttfAPI
svg2ttf(svgFontString, options) -> buf
Parameters:
svgFontString(string) - SVG font content as a stringoptions(object) - Configuration optionscopyright(string, optional) - Copyright textdescription(string, optional) - Font descriptionts(number, optional) - Unix timestamp in seconds to override creation timeurl(string, optional) - Manufacturer URLversion(string, optional) - Font version string (e.g.,Version x.yorx.y)
Returns:
buf- Internal byte buffer object, similar to DataView. Thebufferproperty contains aUint8ArrayorArraywith the TTF content.
Example:
const fs = require('fs');
const svg2ttf = require('@lulliecat/svg2ttf');
const ttf = svg2ttf(fs.readFileSync('myfont.svg', 'utf8'), {});
fs.writeFileSync('myfont.ttf', Buffer.from(ttf.buffer));