svg2glif
Convert SVG-based glyph drawings to UFO's GLIF format.
Overview
svg2glif is a Rust library and command-line tool that converts SVG vector graphics into UFO (Unified Font Object) GLIF format, making it easy to incorporate SVG artwork into font development workflows.
Features
- Convert SVG paths to UFO GLIF format
- Support for cubic Bézier curves
- Configurable units-per-em scaling
- Unicode codepoint assignment
- Proper coordinate system conversion (SVG top-left to UFO baseline)
- Both library and CLI interfaces
Installation
As a CLI tool
As a library
Add to your Cargo.toml:
[]
= "0.1"
Usage
Command Line
Arguments:
-i, --input <INPUT>: Input SVG file-o, --output <OUTPUT>: Output GLIF file-e, --em-size <EM_SIZE>: Units per em (typically 1000 or 2048)-d, --descent <DESCENT>: Descent value to position glyph above baseline-u, --unicode <HEX>: Optional Unicode codepoint in hex (e.g., 0041 for 'A')
Library
use ;
use Path;
let config = new
.with_unicode;
convert_svg_to_glif_file?;
Or convert from SVG string:
use ;
use Path;
let svg_data = r#"<?xml version="1.0" encoding="UTF-8"?>
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<path d="M 10 10 L 90 10 L 90 90 L 10 90 Z" fill="black"/>
</svg>"#;
let config = new;
let glyph = convert_svg_string_to_glyph?;
Limitations
- Only processes
<path>elements (shapes like circles, rectangles must be converted to paths) - Quadratic Bézier curves are not supported (only cubic)
- Does not handle SVG transforms, strokes, or fills
License
MIT