[−][src]Struct riddle_font::TTFont
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]
&self,
text: &str,
pixel_height: u32
) -> Result<Image, FontError>
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]
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> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
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>,