Struct riddle_font::ImgFontBuilder[][src]

pub struct ImgFontBuilder { /* fields omitted */ }

A utility to construct an ImgFont given an image and a collection of glyph data.

Example

let img = Image::new(64, 64);
let mut img_font_builder = ImgFontBuilder::new();
img_font_builder.vertical_spacing(32);

img_font_builder.with_glyph(ImgFontGlyph {
    character: 'a',
    rect: Some(Rect::new([0,0], [32, 32])),
    horizontal_spacing: 32,
    .. Default::default()
});

let img_font = img_font_builder.build(img);

assert_eq!(128, img_font.render_simple("aaaa")?.width());

Implementations

impl ImgFontBuilder[src]

pub fn new() -> Self[src]

Construct a new builder.

pub fn vertical_spacing(&mut self, spacing: u32) -> &mut Self[src]

Set the vertical spacing of the font. See ImgFont::vertical_spacing.

pub fn with_glyph(&mut self, glyph: ImgFontGlyph) -> &mut Self[src]

Register a glyph with the font. If more that one glyph is added with the same value for ImgFontGlyph::character the last one added will be the one that is respected.

pub fn build(self, img: Image) -> ImgFont[src]

Take ownership of the given image, and finalize building of the ImgFont.

Trait Implementations

impl Clone for ImgFontBuilder[src]

impl Debug for ImgFontBuilder[src]

impl Default for ImgFontBuilder[src]

Auto Trait Implementations

impl RefUnwindSafe for ImgFontBuilder

impl Send for ImgFontBuilder

impl Sync for ImgFontBuilder

impl Unpin for ImgFontBuilder

impl UnwindSafe for ImgFontBuilder

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> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.