use-font-size 0.0.1

Primitive font-size helpers
Documentation
  • Coverage
  • 6.25%
    1 out of 16 items documented1 out of 11 items with examples
  • Size
  • Source code size: 5.45 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 388.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-typography
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

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);