Skip to content

Commit

Permalink
fix(inline-emojis): Fix scaling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yuraiz committed Jul 4, 2023
1 parent 634be92 commit 90dbca5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/components/label_with_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,30 @@ mod imp {
if self.widgets.borrow().is_empty() {
self.parent_snapshot(snapshot)
} else {
let (texture, bounds) = {
let snapshot = gtk::Snapshot::new();
let widget = self.obj();

let width = widget.width();
let heigth = widget.height();

let bounds = gtk::graphene::Rect::new(1.0, 0.0, width as f32, heigth as f32);

let texture = {
let s = widget.scale_factor() as f32;

let bounds = bounds.scale(s, s);

let snapshot = gtk::Snapshot::new();
snapshot.scale(s, s);
self.parent_snapshot(&snapshot);

let node = snapshot.to_node().unwrap();
let bounds = node.bounds();

let renderer = gsk::CairoRenderer::new();

renderer.realize(None).unwrap();

let texture = renderer.render_texture(node, Some(&bounds));

renderer.unrealize();

(texture, bounds)
texture
};

snapshot.append_texture(&texture, &bounds)
Expand Down

0 comments on commit 90dbca5

Please sign in to comment.