Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.4.01085.8 KB2026-10-160.3.21087.6 KB2026-10-160.3.11087.5 KB2026-10-160.3.0117.8 KB2026-10-160.2.1106.1 KB2026-10-150.2.0105.5 KB2026-10-15
Version
0.2.0
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-10-15
Size
105.5 KB
Downloads
24
Checksum
f438a48f6f2fc61d892f930eb4fb56fb5a8e302e733a8c3a6283d0ff7350cd08
Dependencies
rust/[email protected]
rust/[email protected]

probe.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
39
40
41
//! 組み上げの途中を覗く。ページ数と、そのページに何が乗ったかを出す
//!
//! 使い方: cargo run --example probe -- 文書.tex [和文の書体]

use hongo::layout::Block;
use hongo::style::Style;
use std::path::Path;


fn main() {
    let argument: Vec<String> = std::env::args().skip(1).collect();
    let path = argument.first().expect("読む文書を書いてください");
    let source = std::fs::read_to_string(path).expect("読めません");
    let base = Path::new(path).parent().unwrap_or(Path::new(".")).to_path_buf();
    let japanese = argument.get(1).map(std::path::PathBuf::from);
    let library = hongo::font::open(
        Path::new("font/latinmodern-math.otf"),
        None,
        None,
        None,
        None,
        None,
        japanese.as_deref(),
    )
    .expect("書体");
    let characters: Vec<char> = source.chars().collect();
    let mut document = hongo::parse::parse(&characters).expect("読み取り");
    let mut numbering = hongo::number::assign(&mut document);
    let style = Style::default();

    for round in 1..=3 {
        let (block, _, _) =
            hongo::layout::build(&document, &library, &style, &numbering, &base).expect("組み上げ");
        let count = block
            .iter()
            .filter(|one| matches!(one, Block::Content {..}))
            .count();
        let (page, _) = hongo::page::paginate(&block, &library, &style, &mut numbering);
        println!("{round} 回目: {} ページ, 中身の行 {count}", page.len());
    }
}