Skip to content
MeanderingProgrammer edited this page Nov 6, 2024 · 29 revisions

Fonts

Preface

I am no expert on font rendering and some of the details below are likely oversimplified. If you find anything to be inaccurate or misleading please let me know!

The goal here is to give someone relatively new to neovim / working in the terminal a decent background and concrete steps to get the kind of experience they want out of their editor. This document is focused entirely on working in the terminal, if you use a GUI then some information may still be helpful, but not as targeted.

If you don't care for any Background skip the next section and look over What I need to do & Troubleshooting.

Background

So you've downloaded neovim and picked up a few plugins, nice! Then you open up your new file tree from neo-tree.nvim or take a look at your status line from lualine.nvim or an awesome markdown renderer :) and you notice the dreaded �, what's going on?

Well, like most people, up until now, you've only ever needed your terminal to display letters, numbers, and the basic symbols you find on your keyboard. So your font, which likely only implements these basic characters was never a problem. Now you want to display complex glyphs / icons, leading to this problem. When your font doesn't implement a particular icon, your terminal emulator (WezTerm, kitty, Alacritty, iTerm2, etc.) doesn't know what to do, so as a last resort will show you the �. You might have some questions so:

Why doesn't my font have these icons?

This is a very niche problem that most fonts don't need to solve. These missing icons are most likely what are referred to as nerd font icons, and there are over 10,000 of them.

The idea of every font shipping with implementations for all these icons is crazy if you think about it. Who out there using Times New Roman in Word is trying to inline the GitHub logo as text? If font authors went through the trouble of making unique icons it would be an insane amount of work for a tiny portion of users. If they shared the same icons and kept the font part unique all fonts would grow many times in size. Maybe not much of a problem now but still wasteful and extra effort.

GUI applications do not come with the same set of limitations as a terminal. They can render an image no problem. Terminals on the other hand are a fixed size grid where we can paint some pixels in each cell. We've essentially taken some UTF-8 encodings and mapped them to icons using the power fonts.

But I didn't add any icons?

Well maybe not directly, but the plugin you're using did. Somewhere in the code for the plugin you'll find the UTF-8 encoded character that represents the icon your font is missing.

Why do we need fancy icons, this is a terminal?

You're technically correct, we do it for the aesthetic :P I'll add that icons, when used effectively, can give you a lot of information at a glance. With file trees for instance they will tell you what's a folder and the type of each file, once you know what you're looking at. It's likely a bit of both and it's totally reasonable to want things to look nice in an environment you spend hours a day in.

The purist may disagree, and the purist is free to use something else or write it themselves.

What I need to do

TODO

Troubleshooting

TODO

Clone this wiki locally