FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ShapedBuffer

    struct · ferroui-base · v0.5.0

    struct ShapedBuffer
    

    A buffer of shaped glyphs: the output of the text shaper for one run.

    Buffers produced by ShapedBuffer::split and ShapedBuffer::with_bidi_level share the glyph storage of their source.

    View source

    Members

    new

    fn new(text: ReadOnlyMemory<u16>, buffer_length: usize, glyph_typeface: Rc<GlyphTypeface>, font_rendering_em_size: f64, bidi_level: i8) -> Rc<Self>
    

    Creates a buffer with room for buffer_length glyphs; the shaper fills it with ShapedBuffer::set.

    Source

    UNSAFE_TO_BREAK

    const UNSAFE_TO_BREAK: u8
    

    The flag of a glyph whose cluster the text may not be cut at, with the two sides shaped apart (HarfBuzz's HB_GLYPH_FLAG_UNSAFE_TO_BREAK).

    Source

    UNSAFE_TO_CONCAT

    const UNSAFE_TO_CONCAT: u8
    

    The flag of a glyph at whose cluster the text may not be changed on one side without changing the shaping of the other (HarfBuzz's HB_GLYPH_FLAG_UNSAFE_TO_CONCAT).

    Source

    set_concat_flags

    fn set_concat_flags(self: &Self, flags: Rc<[u8]>)
    

    Records the concatenation flags of the glyphs, one byte a glyph (Self::UNSAFE_TO_BREAK, Self::UNSAFE_TO_CONCAT): a shaper that was asked for them (TextShaperOptions::produce_concat_flags) sets them once it filled the buffer.

    Source

    concat_flags

    fn concat_flags(self: &Self) -> Option<Rc<[u8]>>
    

    The concatenation flags of the glyphs, when the shaper recorded them.

    Source

    length

    fn length(self: &Self) -> usize
    

    Source

    glyph_infos

    fn glyph_infos(self: &Self) -> Ref<'_, [GlyphInfo]>
    

    Borrows the glyphs. Do not hold the borrow across a call to ShapedBuffer::set.

    Source

    glyph_indices

    fn glyph_indices(self: &Self) -> Ref<'_, [u16]>
    

    The glyph ids of the buffer in glyph order — a contiguous view that mirrors glyph_infos()[i].glyph_index, kept in sync by the setter.

    Source

    glyph_typeface

    fn glyph_typeface(self: &Self) -> &Rc<GlyphTypeface>
    

    The buffer's glyph typeface.

    Source

    font_rendering_em_size

    fn font_rendering_em_size(self: &Self) -> f64
    

    The buffer's font rendering em size.

    Source

    bidi_level

    fn bidi_level(self: &Self) -> i8
    

    The buffer's bidi level.

    Source

    is_left_to_right

    fn is_left_to_right(self: &Self) -> bool
    

    The buffer's reading direction.

    Source

    text

    fn text(self: &Self) -> &ReadOnlyMemory<u16>
    

    The text that is represented by this buffer.

    Source

    dispose

    fn dispose(self: &Self)
    

    Releases the buffer. Idempotent. Afterwards the buffer has no glyphs (length() is zero); the glyph storage itself is freed when the last buffer sharing it is dropped.

    Source

    get

    fn get(self: &Self, index: usize) -> GlyphInfo
    

    Reads the glyph at index.

    Source

    set

    fn set(self: &Self, index: usize, value: GlyphInfo)
    

    Writes the glyph at index.

    Source

    is_cluster_cache_simple

    fn is_cluster_cache_simple(self: &Self) -> bool
    

    True when the cluster cache is in "simple" mode (every cluster is one character wide).

    Source

    total_glyph_advance

    fn total_glyph_advance(self: &Self) -> f64
    

    Sum of all glyph advances in this buffer (cached).

    Source

    first_cluster_char_length

    fn first_cluster_char_length(self: &Self) -> i32
    

    Number of text characters covered by this buffer's first cluster, in logical order. Zero for an empty buffer.

    Source

    cluster_prefix

    fn cluster_prefix(self: &Self) -> Option<Rc<[f64]>>
    

    The shared prefix sum array of the cluster cache, when built.

    Source

    with_bidi_level

    fn with_bidi_level(self: &Rc<Self>, paragraph_embedding_level: i8) -> Rc<ShapedBuffer>
    

    An alias of this buffer with a different bidi level, sharing the glyph storage and (when built) the cluster cache.

    Source

    split

    fn split(self: &Rc<Self>, text_length: i32) -> SplitResult<Rc<ShapedBuffer>>
    

    Splits the buffer at the specified text length (UTF-16 code units).

    Both halves share this buffer's glyph storage and cluster cache.

    Source

    get_char_range_width

    fn get_char_range_width(self: &Self, start_char: i32, end_char: i32) -> f64
    

    Sum of cluster advances over the half-open character range [start_char, end_char) relative to this buffer's text. Snaps both boundaries down to the largest cluster start at or before the given character offset.

    Internal upstream; public so that the Skia unit tests reach it.

    Source

    find_leading_char_count_within_width

    fn find_leading_char_count_within_width(self: &Self, available_width: f64) -> i32
    

    The largest count of leading characters (in logical order) whose cumulative cluster advance fits within available_width, or 0 if not even the first cluster fits.

    Source

    find_trailing_char_count_within_width

    fn find_trailing_char_count_within_width(self: &Self, available_width: f64) -> (i32, f64)
    

    The largest count of trailing characters (in logical order) whose cumulative cluster advance fits within available_width, together with the consumed width. (0, 0.0) if not even the last cluster fits.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.