FontPico

Struct FontPico 

Source
pub struct FontPico;
Expand description

The 4x6 pixel monospace font used by the PICO-fantasy 8 console.

§Examples

§Write some text to the screen at the default (0, 0) position

Text::new("Hello Rust!", Point::new(0, 0))
    .into_styled(TextStyle::new(FontPico, Gray8::WHITE))
    .draw(&mut display);

§Translate text by (20px, 30px)

Text::new("Hello Rust!", Point::new(20, 30))
    .into_styled(TextStyle::new(FontPico, Gray8::WHITE))
    .draw(&mut display);

§Add some styling to the text

Use the TextStyleBuilder trait to edit the colors of the rendered text:

let style = TextStyleBuilder::new(FontPico)
    .text_color(Rgb888::MAGENTA)
    .background_color(Rgb888::BLACK)
    .build();

Text::new("Hello Rust!", Point::new(0, 0))
    .into_styled(style)
    .draw(&mut display);

Trait Implementations§

Source§

impl Clone for FontPico

Source§

fn clone(&self) -> FontPico

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FontPico

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FontPico

Source§

fn default() -> FontPico

Returns the “default value” for a type. Read more
Source§

impl Font for FontPico

Source§

const FONT_IMAGE: &'static [u8] = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xa0\xa0\xe0\xa0\xc0@@@\xa0\x00\x00\x00\x00 \x00@\xa0\xe0\xc0 \xc0\x80\x80 @@\x00\x00\x00@\x00@\x00\xa0`@\xc0\x00\x80 \xe0\xe0\x00\xe0\x00@\x00\x00\x00\xe0\xe0\x80\xa0\x00\x80 @@@\x00\x00@\x00@\x00\xa0@\xa0\xe0\x00@@\xa0\x00\x80\x00@\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\xc0\xe0\xe0\xa0\xe0\x80\xe0\xe0\xe0\x00\x00 \x00\x80\xe0\xa0@ \xa0\x80\x80 \xa0\xa0@@@\xe0@ \xa0@\xe0`\xe0\xe0\xe0 \xe0\xe0\x00\x00\x80\x00 `\xa0@\x80 \xa0 \xa0 @@@\xe0@\x00\xe0\xe0\xe0\xe0 \xe0\xe0 \xe0 \x00\x80 \x00\x80@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xe0\xe0`\xc0\xe0\xe0`\xa0\xe0\xe0\xa0\x80\xe0\xc0`\xa0\xa0\xa0\x80\xa0\x80\x80\x80\xa0@@\xa0\x80\xe0\xa0\xa0\xa0\xe0\xc0\x80\xa0\xc0\xc0\x80\xe0@@\xc0\x80\xa0\xa0\xa0\x80\xa0\xa0\x80\xa0\x80\x80\xa0\xa0@@\xa0\x80\xa0\xa0\xa0`\xa0\xe0`\xe0\xe0\x80\xe0\xa0\xe0\xc0\xa0\xe0\xa0\xa0\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0@\xe0`\xe0\xa0\xa0\xa0\xa0\xa0\xe0\xc0\x80`@\x00\xa0\xa0\xa0\x80@\xa0\xa0\xa0\xa0\xa0 \x80@ \xa0\x00\xe0\xa0\xc0\xe0@\xa0\xa0\xa0@\xe0@\x80@ \x00\x00\x80\xc0\xa0 @\xa0\xe0\xe0\xa0 \x80\x80@ \x00\x00\x80`\xa0\xc0@`@\xe0\xa0\xe0\xe0\xc0 `\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \xe0\xc0\xe0\xc0\xe0\xe0\xe0\xa0\xe0\xe0\xa0\x80\xe0\xc0`\x00\xa0\xc0\x80\xa0\xc0\xc0\x80\xa0@@\xc0\x80\xe0\xa0\xa0\x00\xe0\xa0\x80\xa0\x80\x80\xa0\xe0@@\xa0\x80\xa0\xa0\xa0\x00\xa0\xe0\xe0\xc0\xe0\x80\xe0\xa0\xe0\xc0\xa0\xe0\xa0\xa0\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`@\xc0\x00\x00\xe0@\xe0`\xe0\xa0\xa0\xa0\xa0\xa0\xe0@@@ @\xa0\xa0\xa0\x80@\xa0\xa0\xa0@\xe0 \xc0@`\xe0\xa0\xe0\xc0\xc0 @\xa0\xe0\xe0\xa0 \x80@@@\x80\xa0\x80`\xa0\xc0@`@\xe0\xa0\xe0\xe0`@\xc0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xaa\x82|\x88 8l888|\xfe\x1c|\x10\xfeT\xfe\xc6\"<t|l8|\xe6\xba\x10\xc68\xfe\xaa\xba\xc6\x888||\xee|\xfe\xc6\xfe\x10\xd6|\xfeT\xba\xee\"x|8l8T\xe6\x82p\xc68\xfe\xaa||\x88\x088\x108(\\|\xfep|\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|\x10||\x00\x00|\xfe\xaa\x00\x00\x00\x00\x00\x00\x00\xce88\xee\xa0\x88\xd6\x00\xaa\x00\x00\x00\x00\x00\x00\xaa\xc6\xfe\x10\xc6JT\xee\xfe\xaa\x00\x00\x00\x00\x00\x00\x00\xce|8\xc6\x04\"\xd6\x00\xaa\x00\x00\x00\x00\x00\x00\x00|D||\x00\x00|\xfe\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

Raw image data containing the font.
Source§

const FONT_IMAGE_WIDTH: u32 = 128u32

The width of the raw image data. Read more
Source§

const CHARACTER_SIZE: Size

Size of a single character in pixel.
Source§

fn char_offset(c: char) -> u32

Returns the position a character in the font.
Source§

const CHARACTER_SPACING: u32 = 0u32

Spacing between characters. Read more
Source§

const VARIABLE_WIDTH: bool = false

Whether characters have a variable width or not. Read more
Source§

fn char_width(c: char) -> u32

Returns the actual width of a character in the font.
Source§

fn character_pixel(c: char, x: u32, y: u32) -> bool

Returns the value of a pixel in a character in the font.
Source§

impl Hash for FontPico

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for FontPico

Source§

fn cmp(&self, other: &FontPico) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FontPico

Source§

fn eq(&self, other: &FontPico) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FontPico

Source§

fn partial_cmp(&self, other: &FontPico) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for FontPico

Source§

impl Eq for FontPico

Source§

impl StructuralPartialEq for FontPico

Auto Trait Implementations§

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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>,

Source§

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>,

Source§

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.