Comment by helix278
2 years ago
How would you configure a text editor or terminal to use different fonts based on syntax (e.g. neon for code, argon for comments)?
2 years ago
How would you configure a text editor or terminal to use different fonts based on syntax (e.g. neon for code, argon for comments)?
Hi! I worked on this at Next.
Unfortunately, it's on the editor to support mixing fonts. There's never been multiple compatible monospaced fonts before so no editors really support this yet. Lots of editors also don't support variable typefaces properly yet (ahem, VS Code) but this is going to change.
Ultimately what you're describing is the future! But we have to release the typefaces to bootstrap that future.
We made a prototype extension that hack it into VS Code. But they're hacky af and not really releasable.
> so no editors really support this yet
Emacs and Vim have both supported this since at least last century.
To expand on this, Emacs uses a system called "faces" to draw different textual elements, for example font-lock-comment-face to draw comments. Faces can have different attributes, like font family, foreground colour, background colour, having a box around it,...
So if I want to use a variable pitch font (like say... DejaVu Sans) to draw comments, I can set the font-lock-comment-face to use the "DejaVu Sans" family.
Do you know of any Linux terminal (eg. xterm, gnome-terminal, etc.) that would support multiple fonts? I'm intrigued, shouldn't be very hard to add support to command-line programs (once terminals supported it).
Wezterm does. expansive configuration and scripting abilities are available.
I wonder if terminal escape code sequences would arise to support this too!
I've configured Neovim's syntax highlighting to make comments bold italic, and then I've configured my terminal (Kitty) to display a different font for bold italic text.
Using this approach, you can use up to 4 different fonts: One for normal text, one for italic, one for bold, and one for bold italic. And the font for each group doesn't necessarily need to be that style, e.g. you can use a non-bold version for the `bold` font, etc.
I use kitty and neovim too, would you mind sharing how you got this to work?
In Neovim, make sure your desired highlight groups have `gui=bold,italic`, e.g.
In Kitty, set the desired fonts:
Feels very hacky.
The terminal is by nature very hacky.
In vscode probably easy because it is all CSS?
Other editors/terminal emulators would probably need to add support for this.
Some IDEs support configuring the font per syntactic category, i.e. with the same granularity as syntax highlighting colors.