INNER CODE UNIT · Rust

canvas_width

free-explorers/veshell · src/embedder/backend/render/mod.rs:555

    let canvas_width = (RECORDING_CHIP_WIDTH * integer_scale).round() as i32;
    let canvas_height = (RECORDING_CHIP_HEIGHT * integer_scale).round() as i32;

    // Em size to make digit caps fill most of the chip; the digits share
    // identical metrics, so their common box is the layout reference and
    // everything else (the colon) is centered inside it.
    let px = (RECORDING_CHIP_HEIGHT * 0.72 * integer_scale) as f32;
    let (reference, _) = font.rasterize('0', px);
    let box_height = reference.height as i32;

    let mut placed = Vec::new();
    let mut pen_x = 0i32;
    for glyph in text.chars() {
        let (metrics, bitmap) = font.rasterize(glyph, px);
        let x = pen_x + metrics.xmin;
        let y = ((canvas_height - box_height) / 2) + (box_height - metrics.height as i32) / 2;
        placed.push((x, y, metrics.width as i32, metrics.height as i32, bitmap));
        pen_x += metrics.advance_width.round() as i32;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…