Skip to main content

debug_glyphs

Function debug_glyphs 

Source
pub fn debug_glyphs(
    bytes: &[u8],
    index: usize,
) -> Vec<(char, f32, f32, f32, f32)>
Expand description

Debug: raw glyph stream (ch, ll, lr, lb, lt) (native coords) for page index, before the sanitizer. For comparing char cells to docling-parse.

Examples found in repository?
examples/textparse_glyphs.rs (line 9)
2fn main() {
3    let path = std::env::args().nth(1).expect("pdf");
4    let pi: usize = std::env::args()
5        .nth(2)
6        .and_then(|s| s.parse().ok())
7        .unwrap_or(0);
8    let bytes = std::fs::read(&path).unwrap();
9    let gs = fleischwolf_pdf::textparse::debug_glyphs(&bytes, pi);
10    let s: String = gs.iter().map(|g| g.0).collect();
11    println!("{s}");
12    for (ch, ll, lr, lb, lt) in &gs {
13        eprintln!(
14            "{:?} x0={:7.2} x1={:7.2} yb={:7.2} yt={:7.2}",
15            ch, ll, lr, lb, lt
16        );
17    }
18}