pub struct GlyphStore {
entry_buffer: Vec<GlyphEntry>,
detail_store: DetailedGlyphStore,
total_advance: Au,
total_word_separators: usize,
has_detailed_glyphs: bool,
is_whitespace: bool,
ends_with_whitespace: bool,
is_single_preserved_newline: bool,
is_rtl: bool,
}
Expand description
Stores the glyph data belonging to a text run.
Simple glyphs are stored inline in the entry_buffer
, detailed glyphs are
stored as pointers into the detail_store
.
+- GlyphStore --------------------------------+
| +---+---+---+---+---+---+---+ |
| entry_buffer: | | s | | s | | s | s | | d = detailed
| +-|-+---+-|-+---+-|-+---+---+ | s = simple
| | | | |
| | +---+-------+ |
| | | |
| +-V-+-V-+ |
| detail_store: | d | d | |
| +---+---+ |
+---------------------------------------------+
Fields§
§entry_buffer: Vec<GlyphEntry>
A buffer of glyphs within the text run, in the order in which they appear in the input text. Any changes will also need to be reflected in transmute_entry_buffer_to_u32_buffer().
detail_store: DetailedGlyphStore
A store of the detailed glyph data. Detailed glyphs contained in the
entry_buffer
point to locations in this data structure.
total_advance: Au
A cache of the advance of the entire glyph store.
total_word_separators: usize
A cache of the number of word separators in the entire glyph store. See https://drafts.csswg.org/css-text/#word-separator.
has_detailed_glyphs: bool
Used to check if fast path should be used in glyph iteration.
is_whitespace: bool
Whether or not this glyph store contains only glyphs for whitespace.
ends_with_whitespace: bool
Whether or not this glyph store ends with whitespace glyphs.
Typically whitespace glyphs are placed in a separate store,
but that may not be the case with white-space: break-spaces
.
is_single_preserved_newline: bool
Whether or not this glyph store contains only a single glyph for a single preserved newline.
is_rtl: bool
Implementations§
Source§impl GlyphStore
impl GlyphStore
Sourcepub(crate) fn new(
length: usize,
is_whitespace: bool,
ends_with_whitespace: bool,
is_single_preserved_newline: bool,
is_rtl: bool,
) -> GlyphStore
pub(crate) fn new( length: usize, is_whitespace: bool, ends_with_whitespace: bool, is_single_preserved_newline: bool, is_rtl: bool, ) -> GlyphStore
Initializes the glyph store, but doesn’t actually shape anything.
Use the add_*
methods to store glyph data.
pub fn total_advance(&self) -> Au
pub fn len(&self) -> ByteIndex
pub fn is_whitespace(&self) -> bool
pub fn ends_with_whitespace(&self) -> bool
pub fn total_word_separators(&self) -> usize
pub(crate) fn finalize_changes(&mut self)
fn cache_total_advance_and_word_separators(&mut self)
Sourcepub(crate) fn add_glyph_for_byte_index(
&mut self,
i: ByteIndex,
character: char,
data: &GlyphData,
)
pub(crate) fn add_glyph_for_byte_index( &mut self, i: ByteIndex, character: char, data: &GlyphData, )
Adds a single glyph.
pub(crate) fn add_glyphs_for_byte_index( &mut self, i: ByteIndex, data_for_glyphs: &[GlyphData], )
pub fn iter_glyphs_for_byte_range( &self, range: &Range<ByteIndex>, ) -> impl Iterator<Item = GlyphInfo<'_>> + use<'_>
pub fn advance_for_byte_range( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au
pub(crate) fn advance_for_byte_range_simple_glyphs( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au
pub(crate) fn char_is_word_separator(&self, i: ByteIndex) -> bool
Trait Implementations§
Source§impl Clone for GlyphStore
impl Clone for GlyphStore
Source§fn clone(&self) -> GlyphStore
fn clone(&self) -> GlyphStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GlyphStore
impl Debug for GlyphStore
Source§impl<'de> Deserialize<'de> for GlyphStore
impl<'de> Deserialize<'de> for GlyphStore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl MallocSizeOf for GlyphStore
impl MallocSizeOf for GlyphStore
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for GlyphStore
impl RefUnwindSafe for GlyphStore
impl Send for GlyphStore
impl Sync for GlyphStore
impl Unpin for GlyphStore
impl UnwindSafe for GlyphStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more