Skip to content

FontInfo

What a font file says about itself, as read_font reads it.

use helpers4::font::FontInfo;

Cargo feature font (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features font

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.11", default-features = false, features = ["font"] }
pub struct FontInfo { /* private fields */ }
use helpers4::font::{FontFace, FontInfo, FontStyle};

let info = FontInfo {
    family: "Inter".to_string(),
    style: "Bold Italic".to_string(),
    postscript_name: Some("Inter-BoldItalic".to_string()),
    weight: 700.0,
    weight_range: None,
    italic: true,
};
assert_eq!(info.to_face(), FontFace::new(700.0, FontStyle::Italic));
pub fn to_face(&self) -> FontFace

The face to give to pick_closest: a variable font covers its wght range, a static one its weight.

Returns

FontFace — The face, italic when the font is.

src/font/font_info.rs