Expand description
Text wrapping utilities shared by layout (measuring) and render (drawing).
Widths use Minecraft’s default (ASCII) font advance table so that wrapping and centering match what the MC text renderer actually draws.
Constants§
- CHAR_W
- Approximate pixel width per character at font_scale=1.0 (fallback for non-ASCII chars and legacy callers).
- LINE_
GAP - Gap between wrapped lines.
- LINE_H
- Line height at font_scale=1.0 (MC font is 9px; Patchouli uses 9-10px lines).
Functions§
- char_
width - Advance width in pixels (including 1px inter-glyph spacing) of one char in Minecraft’s default ASCII font at GUI scale 1.
- line_
count - Number of lines that
textwraps to. - paginate_
text - Split
textinto page-sized chunks that fit withinmax_hpixels. Each page is aVec<String>of ready-to-render lines. - str_
width - Pixel width of a string at the given font scale.
- text_
height - Total pixel height of wrapped
text. - wrap_
text - Break
textinto lines that fit withinmax_wpixels atfont_scale. Width accounting is per-glyph (MC default font advances).