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<'a> GlyphStore

source

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.

source

pub fn total_advance(&self) -> Au

source

pub fn len(&self) -> ByteIndex

source

pub fn is_whitespace(&self) -> bool

source

pub fn ends_with_whitespace(&self) -> bool

source

pub fn total_word_separators(&self) -> usize

source

pub fn finalize_changes(&mut self)

source

fn cache_total_advance_and_word_separators(&mut self)

source

pub fn add_glyph_for_byte_index( &mut self, i: ByteIndex, character: char, data: &GlyphData, )

Adds a single glyph.

source

pub fn add_glyphs_for_byte_index( &mut self, i: ByteIndex, data_for_glyphs: &[GlyphData], )

source

pub fn iter_glyphs_for_byte_range( &self, range: &Range<ByteIndex>, ) -> impl Iterator<Item = GlyphInfo<'_>>

source

pub fn range_index_of_advance( &self, range: &Range<ByteIndex>, advance: Au, extra_word_spacing: Au, ) -> (usize, Au)

source

pub fn advance_for_byte_range( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au

source

pub fn advance_for_byte_range_simple_glyphs( &self, range: &Range<ByteIndex>, extra_word_spacing: Au, ) -> Au

source

pub fn char_is_word_separator(&self, i: ByteIndex) -> bool

source

pub fn word_separator_count_in_range(&self, range: &Range<ByteIndex>) -> u32

Trait Implementations§

source§

impl Clone for GlyphStore

source§

fn clone(&self) -> GlyphStore

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GlyphStore

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for GlyphStore

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl MallocSizeOf for GlyphStore

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
source§

impl Serialize for GlyphStore

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T