Skip to main content

Crate use_font_size

Crate use_font_size 

Source
Expand description

Primitive font-size conversions.

These helpers keep size conversions explicit and validate the input sizes used in the calculation.

§Examples

use use_font_size::{FontSize, em_to_px, px_to_rem, rem_to_px};

let font = FontSize::new(18.0).unwrap();

assert!((font.rem(16.0).unwrap() - 1.125).abs() < 1.0e-12);
assert!((px_to_rem(18.0, 16.0).unwrap() - 1.125).abs() < 1.0e-12);
assert!((rem_to_px(1.125, 16.0).unwrap() - 18.0).abs() < 1.0e-12);
assert!((em_to_px(1.5, 12.0).unwrap() - 18.0).abs() < 1.0e-12);

Structs§

FontSize

Enums§

FontSizeError

Functions§

em_to_px
px_to_em
px_to_rem
rem_to_px