Skip to main content

Crate use_text_block

Crate use_text_block 

Source
Expand description

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

Structs§

TextBlock

Enums§

TextBlockError

Functions§

estimated_line_count
estimated_text_height