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.
Members
newUNSAFE_TO_BREAKUNSAFE_TO_CONCATset_concat_flagsconcat_flagslengthglyph_infosglyph_indicesglyph_typefacefont_rendering_em_sizebidi_levelis_left_to_righttextdisposegetsetis_cluster_cache_simpletotal_glyph_advancefirst_cluster_char_lengthcluster_prefixwith_bidi_levelsplitget_char_range_widthfind_leading_char_count_within_widthfind_trailing_char_count_within_width
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.
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).
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).
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.
concat_flags
fn concat_flags(self: &Self) -> Option<Rc<[u8]>>
The concatenation flags of the glyphs, when the shaper recorded them.
length
fn length(self: &Self) -> usize
glyph_infos
fn glyph_infos(self: &Self) -> Ref<'_, [GlyphInfo]>
Borrows the glyphs. Do not hold the borrow across a call to ShapedBuffer::set.
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.
glyph_typeface
fn glyph_typeface(self: &Self) -> &Rc<GlyphTypeface>
The buffer's glyph typeface.
font_rendering_em_size
fn font_rendering_em_size(self: &Self) -> f64
The buffer's font rendering em size.
bidi_level
fn bidi_level(self: &Self) -> i8
The buffer's bidi level.
is_left_to_right
fn is_left_to_right(self: &Self) -> bool
The buffer's reading direction.
text
fn text(self: &Self) -> &ReadOnlyMemory<u16>
The text that is represented by this buffer.
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.
get
fn get(self: &Self, index: usize) -> GlyphInfo
Reads the glyph at index.
set
fn set(self: &Self, index: usize, value: GlyphInfo)
Writes the glyph at index.
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).
total_glyph_advance
fn total_glyph_advance(self: &Self) -> f64
Sum of all glyph advances in this buffer (cached).
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.
cluster_prefix
fn cluster_prefix(self: &Self) -> Option<Rc<[f64]>>
The shared prefix sum array of the cluster cache, when built.
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.
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.
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.
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.
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEither
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.