Struct pixel_game_lib::font::Font

source ·
pub struct Font { /* private fields */ }
Expand description

Pixel font loaded from an image.

Implementations§

source§

impl Font

source

pub fn from_buffer_with_alpha<B>( buffer: B, alpha: u8, char_size: Extent2<u8> ) -> Self
where B: ToBlitBuffer,

Construct the font from a bitmap with an alpha channel.

source

pub fn from_buffer_with_mask_color<B>( buffer: B, mask_color: u32, char_size: Extent2<u8> ) -> Self
where B: ToBlitBuffer,

Construct the font from a bitmap where a single color is the alpha mask.

source

pub fn render( &self, text: &str, position: Vec2<f64>, canvas: &mut [u32], canvas_size: Extent2<usize> )

Render ASCII text on a pixel buffer.

Start from the top-left.

source

pub fn render_centered( &self, text: &str, position: Vec2<f64>, canvas: &mut [u32], canvas_size: Extent2<usize> )

Render ASCII text on a pixel buffer.

Center the text around the point. Currently does not support multi-line strings yet.

Trait Implementations§

source§

impl Debug for Font

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Font

§

impl Send for Font

§

impl Sync for Font

§

impl Unpin for Font

§

impl UnwindSafe for Font

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>