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 設計