Skip to main content

Module text

Module text 

Source
Expand description

Text wrapping utilities shared by layout (measuring) and render (drawing).

Constants§

CHAR_W
Approximate pixel width per character at font_scale=1.0 in Minecraft’s default font.
LINE_GAP
Gap between wrapped lines.
LINE_H
Line height at font_scale=1.0.

Functions§

line_count
Number of lines that text wraps to.
paginate_text
Split text into page-sized chunks that fit within max_h pixels. Each page is a Vec<String> of ready-to-render lines.
text_height
Total pixel height of wrapped text.
wrap_text
Break text into lines that fit within max_w pixels at font_scale. All comparisons are char-count based (Unicode-safe).