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();
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");
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());
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);
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
impl<T> Downcast for T where T: Any, | |
Convert Box<Trait>
(where Trait: Downcast
) to Box<Any>
. Box<Any>
can then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot generate &Any
's vtable from &Trait
's. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot generate &mut Any
's vtable from &mut Trait
's. Read more