How can I easily get the display scale in Rust in a cross-platform way? (Looking for crate recommendations)

I'm writing a tool using minifb that shows things tothe user. I'd like to scale these things based on the display scale. Are there any crates that can get me the display scaling factor in a cross-platform manner? Ideally, there would be a function that I can call to just get it as a float, to avoid any complicated systems.

winit provides access to the scale factor using MonitorHandle::scale_factor, Window::scale_factor, and ScaleFactorChanged event. Note that the scale factor may change dynamically when the user moves the window to another monitor or changes DPI settings.

minifb is not based on winit, so it's hard to integrate them. You could just get the first monitor's scale factor, but it won't cover the multiple monitors case. You can consider switching from minifb to its winit-based alternative, pixels.

I guess that that works as a hacky way of doing it, but the multi-monitor issue does matter. As for using winit+pixels, that's problematic because AFAIK pixels requires a Vulkan-comaptible GPU to do anything, which is problematic for what I'm doing, hence why I'm using minifb.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.