Skip to main content

Module layout

Module layout 

Source
Expand description

Pure text-layout functions: word wrapping and sentence segmentation.

Both functions have zero IO and work on any platform. word_wrap_bytes depends on crate::rendering::text_render for script detection and width measurement, and crate::html_text::Line for output.

Structs§

ScreenLayout

Functions§

block_indent_for
clamp_page
Clamp a page index into [0, page_count-1]. An empty chapter (0 pages) maps any request to 0.
count_chapter_pages
estimate_chapter_offsets
paginate_heights
Paginate row heights into pages that fit within content_h px.
resolve_progress_target
Map a progress-bar per-mille (0..1000) to a (chapter, local_offset) pair using the cumulative chapter-offset table.
sentences_with_ranges
word_wrap_bytes
word_wrap_char_based
Character-granular wrap that preserves every space and tab. Used for <pre> code, where indentation is meaningful and words must not be reflowed, and internally for scripts that do not separate words with spaces.
word_wrap_char_based_styled
As word_wrap_char_based, measured in style. Code wraps in the monospace face, whose advances are wider than the proportional body face – measuring with the wrong one overfills every line.
word_wrap_indent
Like word_wrap_bytes but reserves first_indent px on the first line for a paragraph indent. Only word-spacing scripts indent; the rest wrap unchanged.