Struct ntcip::dms::Font

source ·
pub struct Font<const C: usize = 256> {
    pub number: u8,
    pub name: FStr<64>,
    pub height: u8,
    pub char_spacing: u8,
    pub line_spacing: u8,
    pub characters: [CharacterEntry; C],
}
Expand description

Bitmap font — fontEntry

Fields§

§number: u8

Font number — fontNumber

§name: FStr<64>

Name of font — fontName

§height: u8

Height (pixels) — fontHeight

§char_spacing: u8

Default pixel spacing between characters — fontCharSpacing

§line_spacing: u8

Default pixel spacing between lines — fontLineSpacing

§characters: [CharacterEntry; C]

Characters in font — characterTable

Implementations§

source§

impl<const C: usize> Font<C>

source

pub fn validate(&self) -> Result<(), FontError>

Check if font is valid

source

pub fn version_id(&self) -> u16

Get version ID (fontVersionId)

source

pub fn width(&self) -> u8

Get width (if fixed-width), or 0

source

pub fn character(&self, ch: char) -> Option<&CharacterEntry>

Get a character

source

pub fn text_width(&self, text: &str, cs: Option<u16>) -> Result<u16, FontError>

Calculate the width of a span of text

  • text Span of text.
  • cs Character spacing in pixels.

Trait Implementations§

source§

impl<const C: usize> Clone for Font<C>

source§

fn clone(&self) -> Font<C>

Returns a copy 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<const C: usize> Default for Font<C>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const C: usize> Freeze for Font<C>

§

impl<const C: usize> RefUnwindSafe for Font<C>

§

impl<const C: usize> Send for Font<C>

§

impl<const C: usize> Sync for Font<C>

§

impl<const C: usize> Unpin for Font<C>

§

impl<const C: usize> UnwindSafe for Font<C>

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> 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.