linebender / resvg

An SVG rendering library.
Apache License 2.0
2.85k stars 228 forks source link

Getting exported png without text on linux (github actions) #836

Closed dadyarri closed 1 month ago

dadyarri commented 1 month ago

Hello. i'm generating png images from svg with this code from resvg's example:

pub fn save_png(svg_path: &Path, png_path: &Path) {
    let tree = {
        let mut opt = usvg::Options::default();
        // Get file's absolute directory.
        opt.resources_dir = std::fs::canonicalize(&svg_path)
            .ok()
            .and_then(|p| p.parent().map(|p| p.to_path_buf()));

        opt.fontdb_mut().load_system_fonts();

        let svg_data = std::fs::read(&svg_path).unwrap();
        usvg::Tree::from_data(&svg_data, &opt).unwrap()
    };

    let pixmap_size = tree.size().to_int_size();
    let mut pixmap = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height()).unwrap();
    resvg::render(&tree, tiny_skia::Transform::default(), &mut pixmap.as_mut());
    pixmap.save_png(&png_path).unwrap();
}

and while on windows i'm getting fine images, on github workflow in ubuntu i'm executing same app compiled for x86_64-unknown-linux-gnu, output is missing any text:

image

before generation of images required fonts are installed. please help me understand, why this is working not the way i'm expecting? (i'm rust newbie)

here is Cargo.toml:

[package]
name = "og-builder"
version = "0.1.0"
edition = "2021"

[dependencies]
toml = "0.8.19"
regex = "1.7"
walkdir = "2.5.0"
serde = { version = "1.0.210", features = ["derive"] }
anyhow = "1.0.89"
clap = { version = "4.5.20", features = ["derive"] }
rusttype = "0.9"
git2 = "0.19.0"
chrono = "0.4.38"
resvg = "0.44.0"
LaurenzV commented 1 month ago

Does it work with the resvg CLI application?

RazrFalcon commented 1 month ago

I would also suggest setting up a minimal logger, like env_logger too see what warning are being printed. That should help. Or just use/run the resvg CLI app.

dadyarri commented 1 month ago

Thanks, i managed this