Is posible egui change fonts to japanese ? How?

Hi everyone.

egui is a very nice designer for UI.

So I'm learning to use it for more Japanese apps.

Is it possible to use Japanese font?

How can I change it?

Please teach me.

I haven't used egui much but I seem to remember seeing non-latin screenshots somewhere. In any case the best place to ask is the official egui discussions page: Discussions · emilk/egui · GitHub .

It seems you can set fonts in the Context using set_fonts(). That takes font information that includes a map from font names to font data, and a map from font family to list of fonts used for it in priority order. I think as long as you have a Japanese font in the first map and include it in the list for the font family you are using it should display Japanese characters.

Thanks for the reply.
I was able to find some useful information that I just needed.
I will refer to it.

Here's how to use a custom font on egui.

fn setup(&mut self, ctx: &egui::CtxRef){
        //Custom font install
        // # use epaint::text::*;
        // 1. Create a `FontDefinitions` object.
        let mut font = FontDefinitions::default();
        // Install my own font (maybe supporting non-latin characters):
        // 2. register the font content with a name.
        //font.font_data.insert("mPlus".to_string(), Cow::from(&mPlus_font[..]));
        // 3. Set two font families to use the font, font's name must have been
        // Put new font first (highest priority)registered in `font_data`.
        font.fonts_for_family.get_mut(&FontFamily::Monospace).unwrap().insert(0, "mPlus".to_owned());
        font.fonts_for_family.get_mut(&FontFamily::Proportional).unwrap().insert(0, "mPlus".to_owned());
        // 4. Configure context with modified `FontDefinitions`.
1 Like

Please follow the Forum Code Formatting Guideline.

Thanks for pointing that out.