Struct gfx_glyph::GlyphBrush
[−]
[src]
pub struct GlyphBrush<'font, R: Resources, F: Factory<R>> { /* fields omitted */ }
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
.
Example
extern crate gfx_glyph; use gfx_glyph::Section; let section = Section { text: "Hello gfx_glyph", ..Section::default() }; glyph_brush.queue(section); glyph_brush.queue(some_other_section); glyph_brush.draw_queued(&mut gfx_encoder, &gfx_color, &gfx_depth).unwrap();
Caching behaviour
Calls to GlyphBrush::queue
,
GlyphBrush::pixel_bounds
, GlyphBrush::glyphs
calculate the positioned glyphs for a section.
This is cached so future calls to any of the methods for the same section are much
cheaper. In the case of GlyphBrush::queue
the calculations will also be
used for actual drawing.
The cache for a section will be cleared after a
GlyphBrush::draw_queued
call when that section has not been used since
the previous draw call.
Methods
impl<'font, R: Resources, F: Factory<R>> GlyphBrush<'font, R, F>
[src]
fn queue_custom_layout<'a, S, G>(&mut self, section: S, custom_layout: &G) where
G: GlyphPositioner,
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
G: GlyphPositioner,
S: Into<Cow<'a, VariedSection<'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.
fn queue<'a, S>(&mut self, section: S) where
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
S: Into<Cow<'a, VariedSection<'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.
fn draw_queued<C, T, D>(
&mut self,
encoder: &mut Encoder<R, C>,
target: &RenderTargetView<R, T>,
depth_target: &DepthStencilView<R, D>
) -> Result<(), String> where
C: CommandBuffer<R>,
T: RenderFormat,
D: DepthFormat,
[src]
&mut self,
encoder: &mut Encoder<R, C>,
target: &RenderTargetView<R, T>,
depth_target: &DepthStencilView<R, D>
) -> Result<(), String> where
C: CommandBuffer<R>,
T: RenderFormat,
D: DepthFormat,
Draws all queued sections onto a render target, applying a position transform (e.g.
a projection).
See queue
.
Trims the cache, see caching behaviour.
fn draw_queued_with_transform<C, T, D>(
&mut self,
transform: [[f32; 4]; 4],
encoder: &mut Encoder<R, C>,
target: &RenderTargetView<R, T>,
depth_target: &DepthStencilView<R, D>
) -> Result<(), String> where
C: CommandBuffer<R>,
T: RenderFormat,
D: DepthFormat,
[src]
&mut self,
transform: [[f32; 4]; 4],
encoder: &mut Encoder<R, C>,
target: &RenderTargetView<R, T>,
depth_target: &DepthStencilView<R, D>
) -> Result<(), String> where
C: CommandBuffer<R>,
T: RenderFormat,
D: DepthFormat,
Draws all queued sections onto a render target, applying a position transform (e.g.
a projection).
See queue
.
Trims the cache, see caching behaviour.
fn fonts(&self) -> &HashMap<FontId, Font<'font>>
[src]
Returns FontId
-> Font
map of available fonts.
Trait Implementations
impl<'font, R: Resources, F: Factory<R>> Debug for GlyphBrush<'font, R, F>
[src]
impl<'font, R: Resources, F: Factory<R>> GlyphCruncher<'font> for GlyphBrush<'font, R, F>
[src]
fn pixel_bounds_custom_layout<'a, S, L>(
&mut self,
section: S,
custom_layout: &L
) -> Option<Rect<i32>> where
L: GlyphPositioner + Hash,
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
&mut self,
section: S,
custom_layout: &L
) -> Option<Rect<i32>> where
L: GlyphPositioner + Hash,
S: Into<Cow<'a, VariedSection<'a>>>,
Returns the pixel bounding box for the input section using a custom layout. The box is a conservative whole number pixel rectangle that can contain the section. Read more
fn glyphs_custom_layout<'a, 'b, S, L>(
&'b mut self,
section: S,
custom_layout: &L
) -> PositionedGlyphIter<'b, 'font> where
L: GlyphPositioner + Hash,
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
&'b mut self,
section: S,
custom_layout: &L
) -> PositionedGlyphIter<'b, 'font> where
L: GlyphPositioner + Hash,
S: Into<Cow<'a, VariedSection<'a>>>,
Returns an iterator over the PositionedGlyph
s of the given section with a custom layout. Read more
fn pixel_bounds<'a, S>(&mut self, section: S) -> Option<Rect<i32>> where
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
S: Into<Cow<'a, VariedSection<'a>>>,
Returns the pixel bounding box for the input section. The box is a conservative whole number pixel rectangle that can contain the section. Read more
fn glyphs<'a, 'b, S>(&'b mut self, section: S) -> PositionedGlyphIter<'b, 'font> where
S: Into<Cow<'a, VariedSection<'a>>>,
[src]
S: Into<Cow<'a, VariedSection<'a>>>,
Returns an iterator over the PositionedGlyph
s of the given section. Read more