We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 42dc17d commit 1b4e11aCopy full SHA for 1b4e11a
src/drawing/backend_impl/canvas.rs
@@ -74,8 +74,10 @@ impl DrawingBackend for CanvasBackend {
74
75
fn get_size(&self) -> (u32, u32) {
76
// Getting just canvas.width gives poor results on HighDPI screens.
77
- let rect = self.canvas.get_bounding_client_rect();
78
- (rect.width() as u32, rect.height() as u32)
+ let window = window()?;
+ let mut dpr = window.device_pixel_ratio();
79
+ dpr = if dpr == 0 { 1 } else { dpr };
80
+ ((canvas.width() as f64 / dpr) as u32, (canvas.height() as f64 / dpr) as u32)
81
}
82
83
fn ensure_prepared(&mut self) -> Result<(), DrawingErrorKind<CanvasError>> {
0 commit comments