Struct fonts::GlyphStore
source · 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 fn new(
length: usize,
is_whitespace: bool,
ends_with_whitespace: bool,
is_single_preserved_newline: bool,
is_rtl: bool,
) -> GlyphStore
pub 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 fn finalize_changes(&mut self)
fn cache_total_advance_and_word_separators(&mut self)
sourcepub fn add_glyph_for_byte_index(
&mut self,
i: ByteIndex,
character: char,
data: &GlyphData,
)
pub fn add_glyph_for_byte_index( &mut self, i: ByteIndex, character: char, data: &GlyphData, )
Adds a single glyph.
pub 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<'_>>
pub fn range_index_of_advance( &self, range: &Range<ByteIndex>, advance: Au, extra_word_spacing: Au, ) -> (usize, Au)
pub fn advance_for_byte_range( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au
pub fn advance_for_byte_range_simple_glyphs( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au
pub fn char_is_word_separator(&self, i: ByteIndex) -> bool
pub fn word_separator_count_in_range(&self, range: &Range<ByteIndex>) -> u32
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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