[][src]Struct riddle_font::TTFont

pub struct TTFont { /* fields omitted */ }

Represents a parsed TTF file, and facilitates simple rendering

Implementations

impl TTFont[src]

pub fn new<R: Read>(r: R) -> Result<Self, FontError>[src]

Construct a new TTFont from a Read instance. The source will be read to the end, and the entire buffer parsed as a TTF font file.

let ttf_bytes = include_bytes!("../../example_assets/Roboto-Regular.ttf");
let font = TTFont::new(&ttf_bytes[..])?;

pub fn render_simple(
    &self,
    text: &str,
    pixel_height: u32
) -> Result<Image, FontError>
[src]

Render a string in this font to an image. It will only be a single line of text, even if newlines are present.

Arguments

  • text - The string to be rendered, as a single line of text.
  • pixel_height - The font size (in pixels) to render the font in. The output image will have the same height.

Example

let font = TTFont::new(&ttf_bytes[..])?;
let image = font.render_simple("A String", 24)?;

Auto Trait Implementations

impl RefUnwindSafe for TTFont

impl Send for TTFont

impl Sync for TTFont

impl Unpin for TTFont

impl UnwindSafe for TTFont

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

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.