Quote:
Originally Posted by geek1011
Alternatively, with a bit of code, it should be possible to make some nice bindings between FBInk and resvg.
|
I had a quick try at using resvg with the
bindings I've been working on. Got a basic SVG to print but haven't figured out how to scale it to the screen size yet, and might need to deal with transparency too.
Spoiler:
Code:
use fbink_rs::FbInk;
use resvg::tiny_skia;
use resvg::usvg::{self, fontdb, Size};
fn main() {
let svg_data = include_bytes!("../test.svg");
let fbink = FbInk::new(Default::default()).unwrap();
let state = fbink.state();
let width = state.view_width;
let height = state.view_height;
let size = Size::from_wh(width as f32, height as f32).unwrap();
let tree = {
let opt = usvg::Options {
default_size: size,
dpi: 300.0,
..Default::default()
};
let mut fontdb = fontdb::Database::new();
let font = include_bytes!("../DejaVuSans.ttf");
fontdb.load_font_data(font.to_vec());
usvg::Tree::from_data(svg_data, &opt, &fontdb).unwrap()
};
let mut pixmap = tiny_skia::Pixmap::new(width, height).unwrap();
resvg::render(&tree, Default::default(), &mut pixmap.as_mut());
fbink
.print_raw_data(pixmap.data(), width as i32, height as i32, 0, 0)
.unwrap();
}
Quote:
Originally Posted by gonzule
I'm using a script that collects weather data and replaces some text on a preexisting SVG image with the weather info, but them i am struggling to display this on my kobo.
|
If you don't have any experience with Rust I could try creating a binary that'll display the SVG if you attach an example file that's been processed by your Python script.