joonas-fi / joonas-sys

My personal system installation (Ubuntu + programs & conf I use) as code.
https://joonas.fi/
Apache License 2.0
8 stars 1 forks source link

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

Open joonas-fi opened 1 year ago

joonas-fi commented 1 year ago

Use cases:

image

joonas-fi commented 1 year ago

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 commented 1 year ago

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:

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

Observations

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 commented 1 year ago

End result is starting to look much nicer:

image