效果截图

部分源码如下

use eframe::egui;

pub fn replace_fonts(ctx: &egui::Context) {
    // Start with the default fonts (we will be adding to them rather than replacing them).
    let mut fonts = egui::FontDefinitions::default();

    // Install my own font (maybe supporting non-latin characters).
    // .ttf and .otf files supported.
    fonts.font_data.insert(
        "PuHuiTi".to_owned(),
        std::sync::Arc::new(egui::FontData::from_static(include_bytes!(
            "assets/fonts/Alibaba-PuHuiTi-Regular.ttf"
        ))),
    );

    // Put my font first (highest priority) for proportional text:
    fonts
        .families
        .entry(egui::FontFamily::Proportional)
        .or_default()
        .insert(0, "PuHuiTi".to_owned());

    // Tell egui to use these fonts:
    ctx.set_fonts(fonts);
}