[][src]Struct quicksilver::graphics::FontRenderer

pub struct FontRenderer(_);

A FontRenderer pairs a font source (typically a VectorFont or bitmap font) and a GPU cache for efficient rendering

Instead of uploading glyphs to the GPU every time they're drawn, this method allows for future draws to reference these glyphs multiple times.

Implementations

impl FontRenderer[src]

pub fn from_font(gfx: &Graphics, source: Box<dyn FontProvider>) -> Result<Self>[src]

Create a font from an arbitrary FontProvider

If you want to load a TTF file, consider VectorFont::load and VectorFont::to_renderer instead.

pub fn draw(
    &mut self,
    gfx: &mut Graphics,
    text: &str,
    color: Color,
    offset: Vector
) -> Result<Vector>
[src]

Draw some text to the screen with a given color at a given position, returning the text extents

This method will not wrap but will respect newlines. To wrap, use FontRenderer::draw_wrapping. The returned value is how far the text extended past the offset, e.g. the furthest right and furthest down position.

pub fn draw_wrapping(
    &mut self,
    gfx: &mut Graphics,
    text: &str,
    max_width: Option<f32>,
    color: Color,
    offset: Vector
) -> Result<Vector>
[src]

Draw some text to the screen with a given color at a given position, returning the text extents

If a maximum width is provided, the text will not extend beyond it. If a word encounters the maximum width, it will be wrapped down to a newline. The returned value is how far the text extended past the offset, e.g. the furthest right and furthest down position.

pub fn layout_glyphs(
    &mut self,
    gfx: &mut Graphics,
    text: &str,
    max_width: Option<f32>,
    callback: impl FnMut(&mut Graphics, LayoutGlyph)
) -> Result<Vector>
[src]

Lay out the given text at a given font size, with a given maximum width, returning its extents

Each glyph (and the font) is passed into the callback as it is layed out, giving the option to render right away, examine and move on, etc.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.