pub struct Density {
pub scale: f32,
pub font_scale: f32,
}Expand description
The device pixel grid a Dp or Sp value is measured against: how
many device pixels one Dp is worth, and how far the platform’s text-
size setting scales an Sp beyond that.
This is the pure-data half of Compose’s Density. The composition-aware
wrapper that reads the ambient grid from a running app and reacts to
CompositionLocalProvider-style
overrides lives above this crate (cranpose-ui’s Density, which cannot
live here without an upward dependency on cranpose-ui) and converts
into this type at the boundary.
Fields§
§scale: f32Device pixels per Dp.
font_scale: f32The user’s text-size setting, applied on top of scale for Sp.
Implementations§
Source§impl Density
impl Density
Sourcepub const IDENTITY: Self
pub const IDENTITY: Self
One layout point per device pixel, no extra text scaling – the grid a test or a golden reaches for when the host’s real grid does not matter to what it is checking.
pub fn new(scale: f32, font_scale: f32) -> Self
Sourcepub fn from_scale(scale: f32) -> Self
pub fn from_scale(scale: f32) -> Self
A grid whose text does not follow a separate font-scale setting – what a caller converting a length rather than a text size reaches for, since a length must not move when the user’s text size does.