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.
| Weight | Value |
|---|---|
THIN / W100 | 100 |
EXTRA_LIGHT / W200 | 200 |
LIGHT / W300 | 300 |
NORMAL / W400 | 400 (default) |
MEDIUM / W500 | 500 |
SEMI_BOLD / W600 | 600 |
BOLD / W700 | 700 |
EXTRA_BOLD / W800 | 800 |
BLACK / W900 | 900 |
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.