svg2glif 0.3.1

Convert SVG to UFO glif file
Documentation
use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;
use std::time::Instant;
use svg2glif::{convert_svg_to_glif_file, ConversionConfig};

/// Convert SVG glyphs to UFO GLIF format
#[derive(Parser, Debug)]
#[command(name = "svg2glif")]
#[command(about = "Convert SVG-based glyph drawings to UFO's GLIF format", long_about = None)]
struct Args {
    /// Input SVG file
    #[arg(short, long, value_name = "INPUT")]
    input: PathBuf,

    /// Output GLIF file
    #[arg(short, long, value_name = "OUTPUT")]
    output: PathBuf,

    /// Units per em (typically 1000 or 2048)
    #[arg(short, long, value_name = "EM_SIZE")]
    em_size: f32,

    /// SVG Does not have the concept of ascent-descent, give descent
    /// value to place the glyph above descent
    #[arg(short, long, value_name = "DESCENT")]
    descent: f32,

    /// Unicode codepoint in hex (e.g., 0041 for 'A')
    #[arg(short, long, value_name = "HEX")]
    unicode: Option<String>,
}

fn main() -> Result<()> {
    let args = Args::parse();

    let mut config = ConversionConfig::new(args.em_size, args.descent);
    if let Some(unicode) = args.unicode {
        config = config.with_unicode(unicode);
    }
    let start = Instant::now();
    convert_svg_to_glif_file(&args.input, &args.output, &config)?;
    let elapsed = start.elapsed();
    println!(
        "Wrote glif to {} (took {:.2?})",
        args.output.display(),
        elapsed
    );
    Ok(())
}