Custom font not applying

Open
#138 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
desktop

Research direction

Start by comparing the custom font example with the code in the external app.rs PR, especially the app struct's new function. Read the linked Cargo.toml change involving the default_fonts feature and trace how the eframe template initializes egui. Done means identifying why the font configuration is not taking effect and documenting or fixing the issue in the appropriate project location.

Written by the indexing model from the issue text.

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 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.

Dominant language
Rust
Stars
1.2k
Forks
235
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from emilk/eframe_template

All issues in emilk/eframe_template

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.