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
file and then used in the TextBuffer
, in example:
use glerminal::{TerminalBuilder, Font};
let mut terminal = TerminalBuilder::new()
.with_title("Hello glerminal::font::Font!")
.with_dimensions((1280, 720))
.with_font(Font::load("fonts/iosevka.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};
static IOSEVKA_SFL: &'static str = include_str!("../fonts/iosevka.sfl");
static IOSEVKA_PNG: &'static [u8] = include_bytes!("../fonts/iosevka.png");
let mut terminal = TerminalBuilder::new()
.with_title("Hello glerminal::font::Font!")
.with_dimensions((1280, 720))
.with_font(Font::load_raw(IOSEVKA_SFL, IOSEVKA_PNG))
.with_headless(true)
.build();
Loads the font fron the given .sfl file, for example:
use glerminal::Font;
let font = Font::load("fonts/iosevka.sfl");
Loads the font from the given string (.sfl file contents) and Read (image read)
use glerminal::Font;
use std::fs::File;
let font = Font::load_raw(include_str!("../fonts/iosevka.sfl"), File::open("fonts/iosevka.png").unwrap());
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;
let a_char_data = Font::load("fonts/iosevka.sfl").get_character('a' as u16);
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static