Featured image of post Cómo mostrar japonés en egui

Cómo mostrar japonés en egui

Obtener el ejemplo de egui

Puedes ejecutar el ejemplo de egui con los siguientes comandos.

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

Cargar una fuente compatible con japonés

Para mostrar japonés, es necesario cargar una fuente compatible con este idioma.

En src/app.rs, dentro del método pub fn new, añade las siguientes líneas:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// Cargar fuente compatible con japonés
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);

Ahora podrás mostrar texto en japonés.

img.png

comments powered by Disqus