Skip to main content

quantize_subpixel

Function quantize_subpixel 

Source
fn quantize_subpixel(frac: f32) -> u8
Expand description

Quantize a fractional pixel offset into one of SUBPIXEL_BUCKETS buckets.

Values near 1.0 (>= 0.875 with 4 buckets) are clamped to the last bucket rather than wrapping to 0. Wrapping to bucket 0 without also incrementing the integer pixel coordinate would shift the glyph by ~0.75px in the wrong direction. Clamping keeps the worst-case error to 0.125px.