image/printing: Use cairo renderer for texture
On some systems, to_node -> render_texture generates empty or garbled textures since GTK 4.18 GNOME/gtk#7464. This does not happen when using the cairo renderer. Closes #488
This commit is contained in:
parent
cc061312cd
commit
a49096ffde
2 changed files with 12 additions and 3 deletions
1
news.d/48.1/fixes-print-empty-page
Normal file
1
news.d/48.1/fixes-print-empty-page
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Printed pages don't contain anything or garbled output. This is a temporary workaround for <https://gitlab.gnome.org/GNOME/gtk/-/issues/7464>, using the cairo renderer for the rotation and scaling of the image in the print preparation.
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2023-2024 Sophie Herold
|
// Copyright (c) 2023-2025 Sophie Herold
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -42,8 +42,16 @@ impl LpImage {
|
||||||
.add_to_snapshot(&snapshot, scale, &render_options);
|
.add_to_snapshot(&snapshot, scale, &render_options);
|
||||||
|
|
||||||
let node = snapshot.to_node()?;
|
let node = snapshot.to_node()?;
|
||||||
let renderer = self.root()?.renderer()?;
|
|
||||||
|
|
||||||
Some(renderer.render_texture(&node, None))
|
let renderer = gsk::CairoRenderer::new();
|
||||||
|
renderer
|
||||||
|
.realize_for_display(&gdk::Display::default()?)
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
let texture = renderer.render_texture(&node, None);
|
||||||
|
|
||||||
|
renderer.unrealize();
|
||||||
|
|
||||||
|
Some(texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue