[][src]Struct glerminal::Font

pub struct Font {
    pub name: String,
    pub line_height: u32,
    pub size: u32,
    // some fields omitted
}

The Font is used to load fonts that can be used in the TextBuffer

The Font can be loaded from an .sfl or .fnt file and then used in the TextBuffer, in example:

use glerminal::{TerminalBuilder, Font, FontFormat};

let mut terminal = TerminalBuilder::new()
    .with_title("Hello glerminal::font::Font!")
    .with_dimensions((1280, 720))
    .with_font(Font::load(&FontFormat::SFL, "fonts/source_code_pro.sfl"))
    .with_headless(true)
    .build();

Alternatively you can use load_raw to load the font straight with include_str! and include_bytes!, example:

use glerminal::{TerminalBuilder, Font, FontFormat};

static SCP_SFL: &'static str = include_str!("../fonts/source_code_pro.sfl");
static SCP_PNG: &'static [u8] = include_bytes!("../fonts/source_code_pro.png");

let mut terminal = TerminalBuilder::new()
    .with_title("Hello glerminal::font::Font!")
    .with_dimensions((1280, 720))
    .with_font(Font::load_raw(&FontFormat::SFL, SCP_SFL, SCP_PNG))
    .with_headless(true)
    .build();

Fields

name: String

The name of the font

line_height: u32

Line height of the font

size: u32

Size of the font (width)

Methods

impl Font
[src]

pub fn load<T: Into<PathBuf>>(format: &FontFormat, fnt_path: T) -> Font
[src]

Loads the font fron the given font file, for example:

use glerminal::{Font, FontFormat};
let font = Font::load(&FontFormat::SFL, "fonts/source_code_pro.sfl");

pub fn load_raw<T: Into<String>, R: Read>(
    format: &FontFormat,
    content: T,
    image_read: R
) -> Font
[src]

Loads the font from the given string (font file contents) and Read (image read)

use glerminal::{Font, FontFormat};
use std::fs::File;

let font = Font::load_raw(&FontFormat::SFL, include_str!("../fonts/source_code_pro.sfl"), File::open("fonts/source_code_pro.png").unwrap());

pub fn get_character(&self, character: u16) -> Result<CharacterData, String>
[src]

Gets the CharacterData from the Font with the given char, if the charcter exists, otherwise returns an error as a String. Example:

use glerminal::{Font, FontFormat};
let a_char_data = Font::load(&FontFormat::SFL, "fonts/source_code_pro.sfl").get_character('a' as u16);

Trait Implementations

impl PartialEq<Font> for Font
[src]

impl Debug for Font
[src]

Auto Trait Implementations

impl Send for Font

impl Sync for Font

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Downcast for T where
    T: Any