Skip to content

Instantly share code, notes, and snippets.

@izzqz
Last active March 14, 2024 08:45
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.
@fabiomen10
Copy link

Thanks for share @izzqz
But I'm having this problem.
image

Can you answer me any tip?

@izzqz
Copy link
Author

izzqz commented Oct 3, 2023

Also, this guide seems outdated for the latest version of chromeos. I can't open the console inside of it, and chrome-untrusted://terminal/ can't be opened in the browser. Looks like there is no way to use custom fonts... 😕

@wommy
Copy link

wommy commented Nov 16, 2023

ive been working on this myself for a few days now,
i just found this when searching, along with this post

i can get a few icons to show some of the time, but ive only been playing with it for 15 mins
i.e. works in tmux, but not in neovim, still investigating

@adm304
Copy link

adm304 commented Nov 28, 2023

Hey, i was trying to install it but it seems like the "term_ is not defined", may u help me please
Screenshot 2023-11-28 19 40 41

@izzqz
Copy link
Author

izzqz commented Nov 28, 2023

@adm304 Make sure you are using the console inside the terminal app itself. You can also find it here chrome-untrusted://terminal/html/terminal.html. If you're using the latest version of ChromeOS, unfortunately this won't work as you can't open the js console inside the terminal for now.

@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

@lescx
Copy link

lescx commented Jan 12, 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.

@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