Implement Chinese font loading with NotoSansSC
This commit is contained in:
BIN
fonts/NotoSansSC-Regular.ttf
Normal file
BIN
fonts/NotoSansSC-Regular.ttf
Normal file
Binary file not shown.
19
src/font.rs
19
src/font.rs
@@ -1 +1,18 @@
|
|||||||
pub fn setup_fonts(_ctx: &eframe::egui::Context) {}
|
pub fn setup_fonts(ctx: &eframe::egui::Context) {
|
||||||
|
let mut fonts = eframe::egui::FontDefinitions::default();
|
||||||
|
|
||||||
|
let font_data = include_bytes!("../fonts/NotoSansSC-Regular.ttf");
|
||||||
|
fonts.font_data.insert(
|
||||||
|
"NotoSansSC".to_string(),
|
||||||
|
eframe::egui::FontData::from_static(font_data).into(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if let Some(proportional) = fonts.families.get_mut(&eframe::egui::FontFamily::Proportional) {
|
||||||
|
proportional.insert(0, "NotoSansSC".to_string());
|
||||||
|
}
|
||||||
|
if let Some(monospace) = fonts.families.get_mut(&eframe::egui::FontFamily::Monospace) {
|
||||||
|
monospace.insert(0, "NotoSansSC".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.set_fonts(fonts);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user