Skip to main content

quantize_units

Function quantize_units 

Source
fn quantize_units(pt: f32) -> u32
Expand description

Snap a point measurement to the 1/64-pt grid (§6) and return the canonical bit pattern of that integral count.

Snapping first means two dimensions within one shaper unit fold equal. Dividing is avoided entirely: (pt * 64).round() is already the integral count, and while that count stays below 2^24 (i.e. pt < 262144, ~five orders of magnitude above any real page coordinate) it is represented exactly by f32, so its bit pattern is a canonical, collision-free encoding of that integer. Past 2^24 consecutive counts would alias: out of the domain layout produces, but the bound the i32 form (§9.5) would lift. -0.0, NaN, and non-finite values normalize to 0 so they cannot create spurious distinctions.