pub struct LayoutEngine { /* private fields */ }Expand description
Layout engine for converting tokens to paginated content
Implementations§
Source§impl LayoutEngine
impl LayoutEngine
Sourcepub const DISPLAY_WIDTH: f32 = 480.0
pub const DISPLAY_WIDTH: f32 = 480.0
Default display width in pixels
Sourcepub const DISPLAY_HEIGHT: f32 = 800.0
pub const DISPLAY_HEIGHT: f32 = 800.0
Default display height in pixels
Sourcepub const DEFAULT_MARGIN: f32 = 32.0
pub const DEFAULT_MARGIN: f32 = 32.0
Default side margins in pixels
Sourcepub const DEFAULT_TOP_MARGIN: f32 = 0.0
pub const DEFAULT_TOP_MARGIN: f32 = 0.0
Top margin - minimal
Sourcepub const DEFAULT_HEADER_HEIGHT: f32 = 45.0
pub const DEFAULT_HEADER_HEIGHT: f32 = 45.0
Header area for title (must match renderer HEADER_HEIGHT)
Sourcepub const DEFAULT_FOOTER_HEIGHT: f32 = 40.0
pub const DEFAULT_FOOTER_HEIGHT: f32 = 40.0
Footer area for progress (must match renderer FOOTER_HEIGHT)
Sourcepub fn new(page_width: f32, page_height: f32, line_height: f32) -> Self
pub fn new(page_width: f32, page_height: f32, line_height: f32) -> Self
Create a new layout engine
§Arguments
page_width- Available width for content (excluding margins)page_height- Available height for content (excluding header/footer)line_height- Height of each line in pixels
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create layout engine with default display dimensions
Content area: 416x715 (accounting for margins, header, footer) Uses 10x20 font with 26px line height for comfortable reading
Sourcepub fn with_font_metrics(self, metrics: FontMetrics) -> Self
pub fn with_font_metrics(self, metrics: FontMetrics) -> Self
Set font metrics
Sourcepub fn with_margins(self, left: f32, top: f32) -> Self
pub fn with_margins(self, left: f32, top: f32) -> Self
Set margins
Sourcepub fn layout_tokens(&mut self, tokens: &[Token]) -> Vec<Page>
pub fn layout_tokens(&mut self, tokens: &[Token]) -> Vec<Page>
Convert tokens into laid-out pages
Sourcepub fn into_pages(self) -> Vec<Page>
pub fn into_pages(self) -> Vec<Page>
Get the completed pages
Sourcepub fn current_page_number(&self) -> usize
pub fn current_page_number(&self) -> usize
Get current page number
Sourcepub fn total_pages(&self) -> usize
pub fn total_pages(&self) -> usize
Get total pages created so far
Sourcepub fn measure_text(&self, text: &str, style: TextStyle) -> f32
pub fn measure_text(&self, text: &str, style: TextStyle) -> f32
Measure text width for given string and style
Auto Trait Implementations§
impl Freeze for LayoutEngine
impl RefUnwindSafe for LayoutEngine
impl Send for LayoutEngine
impl Sync for LayoutEngine
impl Unpin for LayoutEngine
impl UnsafeUnpin for LayoutEngine
impl UnwindSafe for LayoutEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more