Incular logoIncular
API ReferenceText & Media

Fonts

FontWeight, FontStyle, and FontFamily with every constant.

FontWeight

use incular::prelude::*;

fn main() {
    let weights = [
        FontWeight::THIN,
        FontWeight::NORMAL,
        FontWeight::MEDIUM,
        FontWeight::BOLD,
        FontWeight::BLACK,
    ];
    println!("bold value: {}", FontWeight::BOLD.value());
    println!("custom: {}", FontWeight::new(450).value());
    println!("count: {}", weights.len());
}

Supports Lerp.

WeightValue
THIN / W100100
EXTRA_LIGHT / W200200
LIGHT / W300300
NORMAL / W400400 (default)
MEDIUM / W500500
SEMI_BOLD / W600600
BOLD / W700700
EXTRA_BOLD / W800800
BLACK / W900900
use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Column::builder()
                    .main_axis_size(MainAxisSize::Min)
                    .spacing(8.0)
                    .children(Vec::<Widget>::from([
                        Text::new("Bold weight").style(
                                TextStyle::new()
                                    .font_weight(FontWeight::BOLD),
                            ).into(),
                        Text::new("Italic system font").style(
                                TextStyle::new()
                                    .font_style(FontStyle::Italic)
                                    .font_family("Inter"),
                            ).into(),
                        Text::new("Custom 600").style(
                                TextStyle::new()
                                    .font_weight(FontWeight::new(600)),
                            ).into(),
                    ]))
                    .build(),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

FontStyle

Normal (default) / Italic, with the .italic() shortcut — exercised in the runnable program above.

FontFamily

SansSerif / Serif / Monospace / Cursive / SystemUi / Named("Inter") (FontFamily::named("Inter")), plus fallback_families(["Inter", "Sans"]) — exercised in the runnable program above.

Related: TextStyle, TextDecoration.

On this page