Skip to content

Commit 90dbca5

Browse files
committed
fix(inline-emojis): Fix scaling issues
1 parent 634be92 commit 90dbca5

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/components/label_with_widgets.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,30 @@ mod imp {
129129
if self.widgets.borrow().is_empty() {
130130
self.parent_snapshot(snapshot)
131131
} else {
132-
let (texture, bounds) = {
133-
let snapshot = gtk::Snapshot::new();
132+
let widget = self.obj();
133+
134+
let width = widget.width();
135+
let heigth = widget.height();
136+
137+
let bounds = gtk::graphene::Rect::new(1.0, 0.0, width as f32, heigth as f32);
138+
139+
let texture = {
140+
let s = widget.scale_factor() as f32;
141+
142+
let bounds = bounds.scale(s, s);
134143

144+
let snapshot = gtk::Snapshot::new();
145+
snapshot.scale(s, s);
135146
self.parent_snapshot(&snapshot);
136147

137148
let node = snapshot.to_node().unwrap();
138-
let bounds = node.bounds();
139149

140150
let renderer = gsk::CairoRenderer::new();
141-
142151
renderer.realize(None).unwrap();
143-
144152
let texture = renderer.render_texture(node, Some(&bounds));
145-
146153
renderer.unrealize();
147154

148-
(texture, bounds)
155+
texture
149156
};
150157

151158
snapshot.append_texture(&texture, &bounds)

0 commit comments

Comments
 (0)