Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot render CJK characters correctly #58

Closed
piaoger opened this issue May 6, 2022 · 3 comments
Closed

Cannot render CJK characters correctly #58

piaoger opened this issue May 6, 2022 · 3 comments

Comments

@piaoger
Copy link

piaoger commented May 6, 2022

CJK characters cannot be handled as shown in below image. Do you have any ideas to resolve it?

1651865032(1)

@jakobhellermann
Copy link
Owner

That is probably an issue with egui. If you try running one of their examples with CJK text, does it work?

@piaoger
Copy link
Author

piaoger commented May 8, 2022

Yes, I cannot find a way to get egui raw context yesterday :)

I fixed that problem by calling setfonts api as following:

fn configure_visuals(mut egui_ctx: ResMut<EguiContext>) {
    egui_ctx.ctx_mut().set_visuals(egui::Visuals {
        window_rounding: 0.0.into(),
        ..Default::default()
    });

    // support customized fonts
    {
        let mut fonts = egui::FontDefinitions::default();

        // Install my own font (maybe supporting non-latin characters):
        // .ttf and .otf supported
           // Put my font first (highest priority):
        fonts.font_data.insert(
            "cjk_font".to_owned(),
            egui::FontData::from_static(include_bytes!("../assets/fonts/adobe/SourceHanSansCN-Normal.otf")),
        );
        fonts
            .families
            .get_mut(&egui::FontFamily::Proportional)
            .unwrap()
            .insert(0, "cjk_font".to_owned());
        egui_ctx.ctx_mut().set_fonts(fonts);
    }
}

image

@jakobhellermann
Copy link
Owner

Awesome, I added a note to the readme: https://github.com/jakobhellermann/bevy-inspector-egui/#common-issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants