Struct native_windows_gui::Font [−][src]
pub struct Font { pub handle: HFONT, }
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
impl Font
[src]
pub fn builder<'a>() -> FontBuilder<'a>
[src]
pub fn set_global_default(font: Option<Font>) -> Option<Font>
[src]
Set the default (application global!) font that will be used when creating controls and return the old one
pub fn set_global_family(family: &str) -> Result<Option<Font>, NwgError>
[src]
Set the default (application global!) font that will be used when creating controls
This is a shortcut over Font::set_global_default
pub fn global_default() -> Option<Font>
[src]
Return the default font that was previously set using Font::set_default
pub fn add_font(path: &str) -> bool
[src]
Add a font to the system font table. Don’t forget to call Font::remove_font(path)
once your 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
pub fn remove_font(path: &str)
[src]
Remove a font that was previously added by Font::add_font
pub fn add_memory_font(bin: &mut [u8]) -> Result<MemFont, ()>
[src]
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.
pub fn remove_memory_font(font: MemFont)
[src]
Remove a font that was previously added by Font::add_memory_font
pub fn families() -> Vec<String>
[src]
Returns all the font families loaded on the OS. Probably pretty slow, so cache the value if possible
Trait Implementations
impl Debug for Font
[src]
impl Default for Font
[src]
impl Eq for Font
[src]
impl PartialEq<Font> for Font
[src]
impl Send for Font
[src]
impl StructuralEq for Font
[src]
impl StructuralPartialEq for Font
[src]
impl Sync for Font
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,