Skip to main content

Crate use_typography

Crate use_typography 

Source
Expand description

Thin facade for the use-typography workspace.

The crate reexports the focused typography crates directly so consumers can opt into one dependency while still using the smaller APIs.

§Examples

use use_typography::*;

let font = FontSize::new(18.0).unwrap();
let line_height = LineHeight::new(18.0, 27.0).unwrap();
let scale = modular_scale(18.0, ScaleRatio::MajorThird, -1, 1).unwrap();

assert!((font.rem(16.0).unwrap() - 1.125).abs() < 1.0e-12);
assert!((line_height.ratio() - 1.5).abs() < 1.0e-12);
assert_eq!(scale.len(), 3);

Re-exports§

pub use use_font_size;
pub use use_line_height;
pub use use_measure;
pub use use_modular_scale;
pub use use_spacing_scale;
pub use use_text_block;
pub use use_type_rhythm;
pub use use_type_unit;

Structs§

FontSize
LineHeight
Measure
SpacingScale
TextBlock
TypeRhythm

Enums§

FontSizeError
LineHeightError
MeasureError
ModularScaleError
ScaleRatio
SpacingScaleError
TextBlockError
TypeRhythmError
TypeUnit
TypeUnitError

Functions§

baseline_grid
characters_per_line
container_width_for_measure
em_to_px
estimated_line_count
estimated_text_height
font_size_em_to_px
font_size_rem_to_px
is_readable_line_height
is_readable_measure
line_height_px
line_height_ratio
modular_scale
pt_to_px
px_to_em
px_to_pt
px_to_rem
rem_to_px
scale_down
scale_up
snap_to_baseline
spacing_step
spacing_steps