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 (to be able to put custom icons) #30

Open
joonas-fi opened this issue Mar 26, 2023 · 3 comments
Open

Custom font (to be able to put custom icons) #30

joonas-fi opened this issue Mar 26, 2023 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@joonas-fi
Copy link
Owner

Use cases:

  • Replace my stupid muscle and candy bar icons with CPU (chip) and RAM module icon

image

@joonas-fi joonas-fi added the enhancement New feature or request label Mar 26, 2023
@joonas-fi
Copy link
Owner Author

joonas-fi commented Apr 25, 2023

Patcher available from: https://github.com/ryanoasis/nerd-fonts

Example font download: https://fonts.google.com/specimen/Roboto

image

Run:

docker run --rm -v /tmp/fonts/in:/in -v /tmp/fonts/out:/out nerdfonts/patcher

Outcome:

/tmp/fonts
├── in
│   ├── LICENSE.txt
│   ├── Roboto-Black.ttf
│   ├── Roboto-BlackItalic.ttf
│   ├── Roboto-Bold.ttf
│   ├── Roboto-BoldItalic.ttf
│   ├── Roboto-Italic.ttf
│   ├── Roboto-Light.ttf
│   ├── Roboto-LightItalic.ttf
│   ├── Roboto-Medium.ttf
│   ├── Roboto-MediumItalic.ttf
│   ├── Roboto-Regular.ttf
│   ├── Roboto-Thin.ttf
│   └── Roboto-ThinItalic.ttf
└── out
    ├── RobotoNerdFont-Black.ttf
    ├── RobotoNerdFont-BlackItalic.ttf
    ├── RobotoNerdFont-Bold.ttf
    ├── RobotoNerdFont-BoldItalic.ttf
    ├── RobotoNerdFont-Italic.ttf
    ├── RobotoNerdFont-Light.ttf
    ├── RobotoNerdFont-LightItalic.ttf
    ├── RobotoNerdFont-Medium.ttf
    ├── RobotoNerdFont-MediumItalic.ttf
    ├── RobotoNerdFont-Regular.ttf
    ├── RobotoNerdFont-Thin.ttf
    └── RobotoNerdFont-ThinItalic.ttf

@joonas-fi
Copy link
Owner Author

joonas-fi commented May 7, 2023

CLI options

Are not discoverable with --help, mainly visible from the README

Icon index

Search icons from here: https://www.nerdfonts.com/cheat-sheet

Patcher adds by default:

  • Seti-UI + Custom Set
    • No interesting icons here
  • Heavy Angle Brackets Set
  • Devicons Set
    • No interesting icons here
  • (tl;dr: by default most icons are not included, you've to add them as CLI options)

Icon sets and code points: https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points

Observations

  • Doesn't seem to contain feature where you can opt-in to only add chosen icons
  • Performance: the minute you start adding large # of glyphs (such as --materialdesignicons), the process takes considerably longer time. That means that if you have lots of variations (see Roboto {Black,BlackItalic,Bold,BoldItalic,...} from above) it's going to take minutes and minutes.
    • Conclusion: don't process a directory but a single chosen .ttf file
    • This would also be mitigated by the "opt-in to only add chosen icons" feature that is missing

Which font to patch?

System fonts are in: /usr/share/fonts/truetype

Let's patch Fira Code from /usr/share/fonts/truetype/firacode/FiraCode-Regular.ttf:

How to patch

docker run --rm -v /usr/share/fonts/truetype/firacode/FiraCode-Regular.ttf:/in/FiraCode-Regular.ttf:ro -v /tmp/fonts/out:/out nerdfonts/patcher --materialdesignicons

Copy the font and rebuild font cache:

sudo cp /tmp/fonts/out/FiraCodeNerd*-Regular.ttf /usr/share/fonts/truetype/firacode/
sudo fc-cache -f -v

How to test

Open text editor (e.g. Mousepad), if you patched FiraCode then the patched font name will be FiraCode Nerd Font

Copy the "Icon" from the cheat sheet - that will be the text "symbol" that gets converted to the icon:

image

@joonas-fi
Copy link
Owner Author

End result is starting to look much nicer:

image

joonas-fi added a commit that referenced this issue Feb 25, 2024
@joonas-fi joonas-fi added this to the High-priority milestone Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant