[−][src]Struct quicksilver::graphics::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]
&mut self,
gfx: &mut Graphics,
text: &str,
color: Color,
offset: Vector
) -> Result<Vector>
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]
&mut self,
gfx: &mut Graphics,
text: &str,
max_width: Option<f32>,
color: Color,
offset: Vector
) -> Result<Vector>
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]
&mut self,
gfx: &mut Graphics,
text: &str,
max_width: Option<f32>,
callback: impl FnMut(&mut Graphics, LayoutGlyph)
) -> Result<Vector>
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
impl !RefUnwindSafe for FontRenderer
impl !Send for FontRenderer
impl !Sync for FontRenderer
impl Unpin for FontRenderer
impl !UnwindSafe for FontRenderer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,