Expand description
Font utilities Font utilities for loading common fonts with multiple weights
This module provides helper functions to easily load popular fonts with multiple weights (regular, medium, semibold, bold) for use in Armas components.
Since egui doesn’t natively support font weights, this module works around the limitation by loading separate font files for each weight and registering them as separate font families.
§Usage
ⓘ
use armas_basic::fonts::{FontWeight, FontFamilyBuilder};
use eframe::egui;
fn setup_fonts(ctx: &egui::Context) {
// Build font definitions
let mut builder = FontFamilyBuilder::new();
builder.add_family(
"Inter",
include_bytes!("../../fonts/Inter-Regular.ttf"),
Some(include_bytes!("../../fonts/Inter-Medium.ttf")),
Some(include_bytes!("../../fonts/Inter-SemiBold.ttf")),
Some(include_bytes!("../../fonts/Inter-Bold.ttf")),
);
// Apply to context (must be done before first frame or in CreationContext)
builder.install(ctx, true); // true = set as default
}
fn my_button(ui: &mut egui::Ui) {
// Use the medium weight variant
let font = FontWeight::medium("Inter", 14.0);
ui.label(egui::RichText::new("Click me").font(font));
}Modules§
- recommended
- Common font recommendations for Aceternity-style UIs
Structs§
- Font
Family Builder - Builder for composing multiple font families
- Font
Weight - Font weight variants