- Notifications
You must be signed in to change notification settings - Fork10
bernsteining/egui_nerdfonts
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
BundlesNerd Fonts icons foregui.
Add the crate as a dependency in Cargo.toml:
egui_nerdfonts ="0.1.3"
or typecargo add egui_nerdfonts
, in your project.
First, update the fonts in your egui context:
letmut fonts = egui::FontDefinitions::default();egui_nerdfonts::add_to_fonts(&mut fonts, egui_nerdfonts::Variant::Regular);let egui_ctx =Context::default();egui_ctx.set_fonts(fonts);
Choose nerdfonts icons you want to use amongthese.
Then use nerdfonts icons as follow:
ui.label(format!("{}", egui_nerdfonts::regular::NF_DEV_RUST));
cargo run --example rust_logo
Got inspired byegui_phosphor, code uses the same structure.
The .ttf used isthis one, and thesrc/variants/regular.rs
was generated with the following python script, with thenerdfonts_regular.ttf
as first argument:
fromitertoolsimportchainfromfontTools.ttLibimportTTFontfromfontTools.unicodeimportUnicodeimportsyswithTTFont(sys.argv[1],0,allowVID=0,ignoreDecompileErrors=True,fontNumber=-1)asttf:chars=chain.from_iterable( [y+ (Unicode[y[0]],)foryinx.cmap.items()]forxinttf["cmap"].tables )forcharinchars:symbol_name=char[1].upper().replace('-','_').replace(' ','_').replace('#','_').replace('!','')code=r"\u"+"{"+f"{char[0]:X}"+"}"print(f"pub const{symbol_name}: &str =\"{code}\";")
About
Nerdfonts icons for egui
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.