use-text-block 0.0.1

Primitive text-block estimation helpers
Documentation
  • Coverage
  • 7.14%
    1 out of 14 items documented1 out of 9 items with examples
  • Size
  • Source code size: 6.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 386.85 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 25s Average build duration of successful builds.
  • all releases: 25s 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 text-block estimation helpers.

These helpers estimate text block layout using explicit widths, average character widths, and line heights.

Examples

use use_text_block::{TextBlock, estimated_line_count, estimated_text_height};

let block = TextBlock::new(480.0, 16.0, 24.0, 120).unwrap();

assert_eq!(block.estimated_characters_per_line(8.0).unwrap(), 60.0);
assert_eq!(block.estimated_line_count(8.0).unwrap(), 2);
assert_eq!(block.estimated_height_px(8.0).unwrap(), 48.0);
assert_eq!(estimated_line_count(120, 60.0).unwrap(), 2);
assert_eq!(estimated_text_height(2, 24.0).unwrap(), 48.0);