Skip to content

Instantly share code, notes, and snippets.

@izzqz
Last active November 12, 2024 13:29
Show Gist options
  • Save izzqz/af36c5bbde67ffff0f7614cf738d75a5 to your computer and use it in GitHub Desktop.
Save izzqz/af36c5bbde67ffff0f7614cf738d75a5 to your computer and use it in GitHub Desktop.
How to setup JetBrains Mono Nerd Font with ligatures to use is inside crostini terminal #guide

Setup Nerd Fonts in Chrome OS terminal

⚠️ This seems outdated and does not work for the latest version of ChromeOS. But feel free to try.

Setup

Press Ctr + Shift + j to open devtools console in crostini terminal.

Paste this to use Jetbrais Mono with ligatures:

term_.prefs_.set('font-family', 'JetBrains Mono Nerd Font, monospace');
term_.prefs_.set('user-css-text', '@font-face {font-family: "JetBrains Mono Nerd Font"; src: url("https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFont-Regular.ttf)"); font-weight: normal; font-style: normal;} x-row {text-rendering: optimizeLegibility;font-variant-ligatures: normal;}')
  1. To change font, replace url path to raw .ttf file with your font in Nerd Fonts repository.
  2. To remove ligatures, delete x-row class in user-css-text parameter.
@juiiyang
Copy link

Is there still a way to use Nerd fonts in the new version of Chrome OS?

@gbishop
Copy link

gbishop commented Dec 23, 2023

I've made some progress on this. First you can open the inspector by going to chrome://inspect/#other then use C-f to search for terminal.html. There will be 2 of them. You want the one with ?command. Click "inspect" and you'll be in the inspector. The next issue will be CORS.
I temporarily got around that by copying the .ttf into a directory being served on localhost.

It Worked!

@gbishop
Copy link

gbishop commented Dec 23, 2023

I've got it working on my Chromebook with an arcane series of hacks. Try it and let me know if it works for you.

https://gist.github.com/gbishop/9803b7ecc50b1930407ef4b98d1ba7c9

@gbishop
Copy link

gbishop commented Jan 12, 2024

I switched to Kitty terminal. Much better all round.

@izzqz
Copy link
Author

izzqz commented Jan 13, 2024

There's no need to tinker with an arcane series of hacks or open the inspect tool. Use Fontconfig. The Debian image comes preinstalled with all the fc-* tools. Just put your font files into ~/.local/share/fonts/ and setup the font config you want, globally or just for your linux user.

Currently AFAIK you can't use any fonts customization natively without development mode. So buying chromebook you are in powerline fonts jail. And you can use fonts only in linux apps inside crostini container, as you mention.

There's very old and staled Issue 320364 about font installation. Hopefully(hah), someone will bring it to life.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment