Primitive typographic unit helpers.
These helpers convert between common typographic units using explicit root and parent font sizes where required.
Examples
use ;
assert!;
assert!;
assert!;
assert!;
assert!;
Primitive typographic unit helpers.
These helpers convert between common typographic units using explicit root and parent font sizes where required.
use use_type_unit::{TypeUnit, em_to_px, pt_to_px, px_to_pt, rem_to_px};
assert!((pt_to_px(12.0).unwrap() - 15.999_996).abs() < 1.0e-12);
assert!((px_to_pt(16.0).unwrap() - 12.000_003_000_000_75).abs() < 1.0e-12);
assert!((rem_to_px(1.25, 16.0).unwrap() - 20.0).abs() < 1.0e-12);
assert!((em_to_px(1.5, 18.0).unwrap() - 27.0).abs() < 1.0e-12);
assert!((TypeUnit::Pt(12.0).to_px(16.0, 18.0).unwrap() - 15.999_996).abs() < 1.0e-12);