Enum glow_glyph::GlyphBrush

source ·
pub enum GlyphBrush<F = FontArc, H = DefaultSectionHasher> {
    Core {
        pipeline: Pipeline,
        glyph_brush: GlyphBrush<Instance, Extra, F, H>,
    },
    Compatibility {
        pipeline: Pipeline,
        glyph_brush: GlyphBrush<[Vertex; 4], Extra, F, H>,
    },
}
Expand description

Object allowing glyph drawing, containing cache state. Manages glyph positioning cacheing, glyph draw caching & efficient GPU texture cache updating and re-sizing on demand.

Build using a GlyphBrushBuilder.

Variants§

§

Core

Fields

§pipeline: Pipeline
§glyph_brush: GlyphBrush<Instance, Extra, F, H>
§

Compatibility

Fields

§pipeline: Pipeline
§glyph_brush: GlyphBrush<[Vertex; 4], Extra, F, H>

Implementations§

source§

impl<F: Font, H: BuildHasher> GlyphBrush<F, H>

source

pub fn queue<'a, S>(&mut self, section: S)
where S: Into<Cow<'a, Section<'a>>>,

Queues a section/layout to be drawn by the next call of draw_queued. Can be called multiple times to queue multiple sections for drawing.

Benefits from caching, see caching behaviour.

source

pub fn queue_custom_layout<'a, S, G>(&mut self, section: S, custom_layout: &G)
where G: GlyphPositioner, S: Into<Cow<'a, Section<'a>>>,

Queues a section/layout to be drawn by the next call of draw_queued. Can be called multiple times to queue multiple sections for drawing.

Used to provide custom GlyphPositioner logic, if using built-in Layout simply use queue

Benefits from caching, see caching behaviour.

source

pub fn queue_pre_positioned( &mut self, glyphs: Vec<SectionGlyph>, extra: Vec<Extra>, bounds: Rect )

Queues pre-positioned glyphs to be processed by the next call of draw_queued. Can be called multiple times.

source

pub fn keep_cached_custom_layout<'a, S, G>( &mut self, section: S, custom_layout: &G )
where S: Into<Cow<'a, Section<'a>>>, G: GlyphPositioner,

Retains the section in the cache as if it had been used in the last draw-frame.

Should not be necessary unless using multiple draws per frame with distinct transforms, see caching behaviour.

source

pub fn keep_cached<'a, S>(&mut self, section: S)
where S: Into<Cow<'a, Section<'a>>>,

Retains the section in the cache as if it had been used in the last draw-frame.

Should not be necessary unless using multiple draws per frame with distinct transforms, see caching behaviour.

source

pub fn fonts(&self) -> &[F]

Returns the available fonts.

The FontId corresponds to the index of the font data.

source

pub fn add_font(&mut self, font: F) -> FontId

Adds an additional font to the one(s) initially added on build.

Returns a new FontId to reference this font.

source§

impl<F: Font + Sync, H: BuildHasher> GlyphBrush<F, H>

source

pub fn draw_queued( &mut self, context: &Context, target_width: u32, target_height: u32 ) -> Result<(), String>

Draws all queued sections onto a render target. See queue.

Trims the cache, see caching behaviour.

§Panics

Panics if the provided target has a texture format that does not match the render_format provided on creation of the GlyphBrush.

source

pub fn draw_queued_with_transform( &mut self, context: &Context, transform: [f32; 16] ) -> Result<(), String>

Draws all queued sections onto a render target, applying a position transform (e.g. a projection). See queue.

Trims the cache, see caching behaviour.

§Panics

Panics if the provided target has a texture format that does not match the render_format provided on creation of the GlyphBrush.

source

pub fn draw_queued_with_transform_and_scissoring( &mut self, context: &Context, transform: [f32; 16], region: Region ) -> Result<(), String>

Draws all queued sections onto a render target, applying a position transform (e.g. a projection) and a scissoring region. See queue.

Trims the cache, see caching behaviour.

§Panics

Panics if the provided target has a texture format that does not match the render_format provided on creation of the GlyphBrush.

Trait Implementations§

source§

impl<F, H> Debug for GlyphBrush<F, H>

source§

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

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

impl<F: Font, H: BuildHasher> GlyphCruncher<F> for GlyphBrush<F, H>

source§

fn glyphs_custom_layout<'a, 'b, S, L>( &'b mut self, section: S, custom_layout: &L ) -> SectionGlyphIter<'b>
where L: GlyphPositioner + Hash, S: Into<Cow<'a, Section<'a>>>,

Returns an iterator over the PositionedGlyphs of the given section with a custom layout. Read more
source§

fn glyph_bounds_custom_layout<'a, S, L>( &mut self, section: S, custom_layout: &L ) -> Option<Rect>
where L: GlyphPositioner + Hash, S: Into<Cow<'a, Section<'a>>>,

Returns a bounding box for the section glyphs calculated using each glyph’s vertical & horizontal metrics. Read more
source§

fn fonts(&self) -> &[F]

Returns the available fonts. Read more
source§

fn glyphs<'a, 'b, S>(&'b mut self, section: S) -> Iter<'b, SectionGlyph>
where X: 'a, S: Into<Cow<'a, Section<'a, X>>>,

Returns an iterator over the PositionedGlyphs of the given section. Read more
source§

fn glyph_bounds<'a, S>(&mut self, section: S) -> Option<Rect>
where X: 'a, S: Into<Cow<'a, Section<'a, X>>>,

Returns a bounding box for the section glyphs calculated using each glyph’s vertical & horizontal metrics. Read more

Auto Trait Implementations§

§

impl<F, H> Freeze for GlyphBrush<F, H>
where H: Freeze,

§

impl<F, H> RefUnwindSafe for GlyphBrush<F, H>

§

impl<F, H> Send for GlyphBrush<F, H>
where H: Send, F: Send,

§

impl<F, H> Sync for GlyphBrush<F, H>
where H: Sync, F: Sync,

§

impl<F, H> Unpin for GlyphBrush<F, H>
where H: Unpin, F: Unpin,

§

impl<F, H> UnwindSafe for GlyphBrush<F, H>
where H: UnwindSafe, F: UnwindSafe,

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, 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> 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, 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