Skip to main content

host_density

Function host_density 

Source
pub fn host_density() -> f32
Expand description

How many physical pixels this host puts in one logical pixel.

One number, from wherever this platform keeps it: the activity configuration on Android, the screen’s backing scale on macOS and iOS, the window’s scale factor on desktop, devicePixelRatio in a browser. An application asking “how big is a hairline here” reads this rather than the platform API behind it.

Before the first surface exists this is 1.0 — the honest answer, since nothing has been measured yet — so a caller that needs the real value waits for a frame or observes rememberHostSurfaceSize.