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

Set the default (application global!) font that will be used when creating controls and return the old one

Set the default (application global!) font that will be used when creating controls This is a shortcut over Font::set_global_default

Return the default font that was previously set using Font::set_default

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 a ttf or a otf font.
  • Adding the same font multiple time increase the internal refcount
  • Use Font::families() to return the available system font families

Remove a font that was previously added by Font::add_font

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.

Remove a font that was previously added by Font::add_memory_font

Returns all the font families loaded on the OS. Probably pretty slow, so cache the value if possible

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.