emilk / emilk/eframe_template

Custom font not applying

Open
#138 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.2k
Forks
230
Avg merge
11m
Merged PRs (30d)
1

Description

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](https://github.com/emilk/egui/blob/master/examples/custom_font/src/main.rs) 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](https://github.com/pmillspaugh/stickies/pull/2/files), and here's the code I added to the `new` fn in my app struct impl in `app.rs`:

```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](https://github.com/pmillspaugh/stickies/blob/main/Cargo.toml#L17) to break fonts altogether, but my app still built and ran.

Thank you.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.