Skip to main content

TextGeometry

Trait TextGeometry 

Source
pub trait TextGeometry {
    // Required methods
    fn metrics(&self) -> TextMetrics;
    fn line_count(&self) -> usize;
    fn get_line(&self, index: usize) -> Option<TextLineRef<'_>>;
    fn lines(&self) -> TextLines<'_> ⓘ;
    fn lines_between(&self, top: f32, bottom: f32) -> TextLines<'_> ⓘ;
    fn line_for_offset(&self, byte: usize) -> usize;
    fn line_caret_positions(&self, line: usize) -> &[TextCaretPosition];

    // Provided method
    fn line(&self, index: usize) -> TextLineRef<'_> { ... }
}
Expand description

Line geometry of laid-out text: lines in layout coordinates, their caret stops and the overall metrics.

TextLayout implements it for one shaped text, and TextDocumentLayout for a document laid out paragraph by paragraph.

Required Methods§

Source

fn metrics(&self) -> TextMetrics

Source

fn line_count(&self) -> usize

Source

fn get_line(&self, index: usize) -> Option<TextLineRef<'_>>

Source

fn lines(&self) -> TextLines<'_> ⓘ

Source

fn lines_between(&self, top: f32, bottom: f32) -> TextLines<'_> ⓘ

Lines that may meet the vertical span top..bottom, plus one line on each side; pad the span for glyphs that overhang their line.

Source

fn line_for_offset(&self, byte: usize) -> usize

Index of the line whose [start, end) holds byte, or the last line when none does, like Flutter’s Paragraph.getLineBoundary.

Source

fn line_caret_positions(&self, line: usize) -> &[TextCaretPosition]

The visual insertion points of one line in left-to-right screen order.

Provided Methods§

Source

fn line(&self, index: usize) -> TextLineRef<'_>

The line at index.

§Panics

Panics when index is not below TextGeometry::line_count.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: TextGeometry + ?Sized> TextGeometry for Arc<T>

Layouts are shared as Arcs; geometry reads through them unchanged.

Source§

fn metrics(&self) -> TextMetrics

Source§

fn line_count(&self) -> usize

Source§

fn get_line(&self, index: usize) -> Option<TextLineRef<'_>>

Source§

fn lines(&self) -> TextLines<'_> ⓘ

Source§

fn lines_between(&self, top: f32, bottom: f32) -> TextLines<'_> ⓘ

Source§

fn line_for_offset(&self, byte: usize) -> usize

Source§

fn line_caret_positions(&self, line: usize) -> &[TextCaretPosition]

Implementors§