Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.2.0579.9 KB2026-09-150.1.1576.6 KB2026-09-12
Version
0.2.0
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-09-15
Size
579.9 KB
Downloads
2
Checksum
58312d92e63a92784e82a974317afd849e59d143a6320c3cc62faa0980834a7b
Dependencies
None

pick.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
//! 波括弧がどの字形を選んでいるかを見る

use suki::font;
use suki::layout::Content;
use suki::node::Style;
use suki::{layout, parse};

fn main() {
    let loaded = font::load(std::fs::read("font/latinmodern-math.otf").unwrap()).unwrap();
    let mut body = String::from("a");

    for step in 0..6 {
        if step > 0 {
            body.push_str("+a");
        }

        let source = format!(r"\overbrace{{{body}}}");
        let node = parse(&source).unwrap();
        let placed = layout::layout(&node, &loaded, 1.0, Style::Auto, true);
        let Content::Group(row) = &placed.content else {continue};
        let Content::Group(parts) = &row[0].layout.content else {continue};
        let inside = &parts[0].layout;
        let mark = &parts[1].layout;
        let shape = match &mark.content {
            Content::Glyph {glyph, ..} => format!("字形 {glyph}"),
            Content::Group(pieces) => format!("部品 {} 個", pieces.len()),
            Content::Rule => "線".to_string(),
        };
        println!(
            "中身の幅 {:.3}  印 {shape}  幅 {:.3}  高さ {:.3}  深さ {:.3}",
            inside.width, mark.width, mark.height, mark.depth
        );
    }
}