Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.2.3555.5 KB2026-10-160.2.2572.8 KB2026-10-150.2.1580.5 KB2026-10-150.2.0579.9 KB2026-09-150.1.1576.6 KB2026-09-12
Version
0.2.2
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-10-15
Size
572.8 KB
Downloads
28
Checksum
ce26f898ba26eb49c71ebc68597f62f268b83e41bb265b1b5a01688966054588
Dependencies
None

glyphs.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Shows the specified glyphs as they are, one after another

use suki::font;
use suki::outline::{bounds, path_data};
use suki::text::number;

fn main() {
    let loaded = font::load(std::fs::read("font/latinmodern-math.otf").unwrap()).unwrap();
    let units = font::units_per_em(&loaded);
    let wanted: Vec<u16> = std::env::args()
        .skip(1)
        .filter_map(|value| value.parse().ok())
        .collect();

    println!("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>Glyphs</title>");
    println!("<style>body{{margin:0;padding:24px;font-family:system-ui,sans-serif;font-size:12px}}");
    println!(".row{{margin-bottom:20px}}.name{{color:#767676;margin-bottom:4px}}</style></head><body>");

    for glyph in wanted {
        let drawn = font::outline_of(&loaded, glyph);
        let (left, bottom, right, top) = bounds(&drawn);
        let width = (right - left) / units;
        let height = (top - bottom) / units;
        println!("<div class=\"row\"><div class=\"name\">glyph {glyph}</div>");
        println!(
            "<svg width=\"{}px\" height=\"{}px\" viewBox=\"{} {} {} {}\" fill=\"#1f1f1f\"><path d=\"{}\"/></svg></div>",
            number(width * 200.0),
            number(height * 200.0),
            number(left / units),
            number(-top / units),
            number(width),
            number(height),
            path_data(&drawn, 1.0 / units, 0.0, 0.0)
        );
    }

    println!("</body></html>");
}