Struct native_windows_gui::Font
source · [−]pub struct Font {
pub handle: HFONT,
}
Expand description
Represent a system font.
Can be used with any controls that draws text. Due to the very limited way win32 can draw text, only family, size and weight can be configured.
Example:
use native_windows_gui as nwg;
fn build_font() -> nwg::Font {
let mut font = nwg::Font::default();
nwg::Font::builder()
.size(16)
.family("Arial")
.weight(1000)
.build(&mut font);
font
}
Fields
handle: HFONT
Implementations
sourceimpl Font
impl Font
pub fn builder<'a>() -> FontBuilder<'a>
sourcepub fn set_global_default(font: Option<Font>) -> Option<Font>
pub fn set_global_default(font: Option<Font>) -> Option<Font>
Set the default (application global!) font that will be used when creating controls and return the old one
sourcepub fn set_global_family(family: &str) -> Result<Option<Font>, NwgError>
pub fn set_global_family(family: &str) -> Result<Option<Font>, NwgError>
Set the default (application global!) font that will be used when creating controls
This is a shortcut over Font::set_global_default
sourcepub fn global_default() -> Option<Font>
pub fn global_default() -> Option<Font>
Return the default font that was previously set using Font::set_default
sourcepub fn add_font(path: &str) -> bool
pub fn add_font(path: &str) -> bool
Add a font to the system font table. Don’t forget to call Font::remove_font(path)
once you’re done.
Returns false
if the font could not be added. Windows won’t tell you why though.
Other info:
- The value of
path
can be attf
or aotf
font. - Adding the same font multiple time increase the internal refcount
- Use
Font::families()
to return the available system font families
sourcepub fn remove_font(path: &str)
pub fn remove_font(path: &str)
Remove a font that was previously added by Font::add_font
sourcepub fn add_memory_font(bin: &mut [u8]) -> Result<MemFont, ()>
pub fn add_memory_font(bin: &mut [u8]) -> Result<MemFont, ()>
Add a font resource from a binary source. Returns a memory font handle if the font was loaded succesfully.
Send the handle to remove_memory_font
at the end of your program to free the font from memory.
sourcepub fn remove_memory_font(font: MemFont)
pub fn remove_memory_font(font: MemFont)
Remove a font that was previously added by Font::add_memory_font
Trait Implementations
sourceimpl PartialEq<Font> for Font
impl PartialEq<Font> for Font
impl Eq for Font
impl Send for Font
impl StructuralEq for Font
impl StructuralPartialEq for Font
impl Sync for Font
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more