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
//! Shows which glyph the brace chooses
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 {glyph}"),
Content::Group(pieces) => format!("parts {}", pieces.len()),
Content::Rule => "rule".to_string(),
};
println!(
"content width {:.3} accent {shape} width {:.3} height {:.3} depth {:.3}",
inside.width, mark.width, mark.height, mark.depth
);
}
}