pretext 0.1.0

Native Unicode text preparation and paragraph layout engine for Pretext.
Documentation
//! Advanced `pretext` APIs.
//!
//! These exports expose lower-level layout, cursor, shaping, and font details
//! used by custom editors, obstacle-aware flow, and debugging tools.

use crate::{
    PretextEngine, PretextParagraphMetrics, PretextParagraphOptions, PretextPreparedParagraph,
    PretextStyle,
};

pub use crate::engine::{
    LayoutCursor, LayoutGlyph, LayoutLine, LayoutLineRange, LayoutLineRuns,
    LayoutLineWithGlyphRuns, LayoutWithLinesResult, LineGeometry, PreparedText, SegmentKind,
    ShapedTextSpan,
};
pub use crate::font_catalog::{FontId, LoadedFace};
pub use crate::line_break::BreakOpportunity;
pub use crate::measure::{shape_run, ShapeCache, ShapedGlyph};

pub fn prepare_text(
    engine: &PretextEngine,
    text: &str,
    style: &PretextStyle,
    options: &PretextParagraphOptions,
) -> PreparedText {
    engine.prepare(text, style, options)
}

pub fn measure_text(
    engine: &PretextEngine,
    prepared: &PreparedText,
    max_width: f32,
    line_height: f32,
) -> PretextParagraphMetrics {
    engine.layout(prepared, max_width, line_height)
}

pub fn layout_lines(
    engine: &PretextEngine,
    prepared: &PretextPreparedParagraph,
    max_width: f32,
    line_height: f32,
) -> LayoutWithLinesResult {
    engine.layout_with_lines(prepared, max_width, line_height)
}

pub fn measure_line_geometry(
    engine: &PretextEngine,
    prepared: &PretextPreparedParagraph,
    max_width: f32,
) -> LineGeometry {
    prepared.measure_line_geometry(engine, max_width)
}

pub fn measure_natural_width(engine: &PretextEngine, prepared: &PretextPreparedParagraph) -> f32 {
    prepared.measure_natural_width(engine)
}

pub fn layout_next_line_range(
    engine: &PretextEngine,
    prepared: &PretextPreparedParagraph,
    start: &mut LayoutCursor,
    max_width: f32,
) -> Option<LayoutLineRange> {
    prepared.layout_next_line_range(engine, start, max_width)
}