Featured image of post 如何在egui中显示日语

如何在egui中显示日语

获取egui示例

可以使用以下命令运行egui的示例。

1
2
3
git clone https://github.com/emilk/eframe_template/ egui_test
cd egui_test
cargo run

加载支持日语的字体

要显示日语,必须加载支持日语的字体。

src/app.rs 中的 pub fn new 方法中添加以下代码行。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// 加载支持日语的字体
let mut fonts = egui::FontDefinitions::default();
fonts.font_data.insert(
    "Meiryo".to_owned(),
    egui::FontData::from_static(include_bytes!("C:/Windows/Fonts/Meiryo.ttc")),
);
fonts
    .families
    .entry(egui::FontFamily::Proportional)
    .or_default()
    .insert(0, "Meiryo".to_owned());
cc.egui_ctx.set_fonts(fonts);

现在就可以显示日语了。

img.png

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计