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

Custom font not applying #138

Open
pmillspaugh opened this issue Jun 6, 2024 · 2 comments
Open

Custom font not applying #138

pmillspaugh opened this issue Jun 6, 2024 · 2 comments

Comments

@pmillspaugh
Copy link

Hi there,

I am trying out eframe/egui for the first time (thanks for all the docs and examples!).

I'm following the custom font example to add a custom font to my own eframe app, but my custom font is not applying. I'm guessing that I'm making a simple mistake. PR here, and here's the code I added to the new fn in my app struct impl in app.rs:

let mut fonts = egui::FontDefinitions::default();

fonts.font_data.insert(
    "EBGaramond".to_owned(),
    egui::FontData::from_static(include_bytes!("../assets/EBGaramond-Regular.ttf"))
);

fonts.families.entry(egui::FontFamily::Proportional).or_default().insert(0,"EBGaramond".to_owned());
fonts.families.entry(egui::FontFamily::Monospace).or_default().insert(0,"EBGaramond".to_owned());

cc.egui_ctx.set_fonts(fonts);

I also tried removing the default_fonts feature in Cargo.toml to break fonts altogether, but my app still built and ran.

Thank you.

@markusdd
Copy link
Contributor

You can check out the section from one of my apps here, hope it helps: https://github.com/markusdd/rusty_meter/blob/054149fa6114bda3b2e91a5261d3e70baf3692c1/src/app.rs#L320

@pmillspaugh
Copy link
Author

Thanks, @markusdd! Still no luck with the approach you took unfortunately, but I'll report back here if I can find the issue.

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