Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nerdfonts icons for egui

NotificationsYou must be signed in to change notification settings

bernsteining/egui_nerdfonts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BundlesNerd Fonts icons foregui.

NerdFonts

Installation

Add the crate as a dependency in Cargo.toml:

egui_nerdfonts ="0.1.3"

or typecargo add egui_nerdfonts, in your project.

Usage

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));

Example

cargo run --example rust_logo

output

About

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp