kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.87k stars 964 forks source link

Small sized nerdfont symbols #1463

Closed mmequignon closed 5 years ago

mmequignon commented 5 years ago

Hi !

I just migrated from terminator to kitty and I pretty love this term. I do not use tmux anymore except for specifig things.

Actually, I gave a little issue : glyphes are displayed very small, compared with terminator, as you can see in this screenshot

2019-03-13-17:50:24-screenshot

(kitty on top, terminator on the bottom)

FYI, I tested the pre-built installable version and the debian sid package version 0.13.3-1 as well. The font is FiraCode (without nerdfonts) and I have apparently nerdfonts installed separately (I have this configuration for a very long time I can't remember the way I installed it). Oh, and this is oh-my-zsh with the powerlevel9k theme that displays those symbols (I don't know if it's a clue).

Actually, I'm not sure that this is a kitty issue, but it would be nice if you could help me.

And btw it will maybe help other users…

Luflosi commented 5 years ago

To print the character and reproduce the problem: python3 -c 'print("Single cell:\t>\uf296<\nTwo cells:\t>\uf296 <")'.

kovidgoyal commented 5 years ago

Nerd fonts use private use unicode characters. These are all single cell characters. If you want them rendered in more than a single cell, you have to follow them with one or more spaces, then kitty will use the space cells to render the character as needed.

Luflosi commented 5 years ago

As you can see, following it with a space does render the character in two cells but the size is exactly the same. Would it be possible to make it bigger? Bildschirmfoto 2019-03-14 um 01 59 20

mmequignon commented 5 years ago

To print the character and reproduce the problem: python3 -c 'print("Single cell:\t>\uf296<\nTwo cells:\t>\uf296 <")'.

Should I get the same glyphe in two different sizes ? This is what I get : 2019-03-14-02:00:50-screenshot

kovidgoyal commented 5 years ago

yes, like this:

Screenshot_20190314_063520

kovidgoyal commented 5 years ago

With a space it is rendered bigger. However, given this glyph is tall and narrow I dont see how it can be rendered much bigger, without clipping vertically. Remember that kitty, unlike most terminals renders things inside cells, it does not allow overflow into neighboring cells.

Luflosi commented 5 years ago

Kinda weird, that the alignment and size is different for me. For me they are both exactly the same size. Anyways, I selected the two cells to demonstrate how big they are and there is definitely a lot more room: Bildschirmfoto 2019-03-14 um 02 09 15

mmequignon commented 5 years ago

Both are the same size here too, but mine isn't centered. 2019-03-14-02:14:51-screenshot

edit : FYI each prompt segment is space separated.

kovidgoyal commented 5 years ago

Use --debug-font-fallback to check what actual font your symbol is coming from. For me it is 3270Medium Nerd Font Mono which appears to render larger glyphs as expected.

Luflosi commented 5 years ago

For me it's MesloLGM Nerd Font Mono.

kovidgoyal commented 5 years ago

You shouldn't need to use a patched font in order to make use of NERD fonts with kitty. Try just installing the normal nerd font, kitty should fallback to it automatically for PUA characters and if not you can tell it to via symbol_map

Luflosi commented 5 years ago

I am using it via symbol_map: symbol_map U+23FB-U+23FE,U+2B58,U+E200-U+E2A9,U+E0A0-U+E0A3,U+E0B0-U+E0BF,U+E0C0-U+E0C8,U+E0CC-U+E0CF,U+E0D0-U+E0D2,U+E0D4,U+E700-U+E7C5,U+F000-U+F2E0,U+2665,U+26A1,U+F400-U+F4A8,U+F67C,U+E000-U+E00A,U+F300-U+F313,U+E5FA-U+E62B MesloLGM Nerd Font Mono

mmequignon commented 5 years ago

Thank you ! I just installed this font and it works as expected now !

kovidgoyal commented 5 years ago

On Wed, Mar 13, 2019 at 06:26:38PM -0700, Luflosi wrote:

I am using it via symbol_map: symbol_map U+23FB-U+23FE,U+2B58,U+E200-U+E2A9,U+E0A0-U+E0A3,U+E0B0-U+E0BF,U+E0C0-U+E0C8,U+E0CC-U+E0CF,U+E0D0-U+E0D2,U+E0D4,U+E700-U+E7C5,U+F000-U+F2E0,U+2665,U+26A1,U+F400-U+F4A8,U+F67C,U+E000-U+E00A,U+F300-U+F313,U+E5FA-U+E62B MesloLGM Nerd Font Mono

yes but use the non-patched nerfonts release rather than a patched version of Menlo. Auto-patching of fonts rarely works perfectly.

mmequignon commented 5 years ago

I didn't know, thank you for your time !

Luflosi commented 5 years ago

I installed the 3270 Nerd Font from https://nerdfonts.com and replaced MesloLGM Nerd Font Mono in symbol_map with 3270Medium Nerd Font Mono. It made no visual difference for me, the two characters still have the same size. I also tried uninstalling the font again and installed to the font linked by @mmequignon, which also made no difference. kitty --debug-font-fallback shows that 3270Medium Nerd Font Mono is being used. screenshot

kovidgoyal commented 5 years ago

Try using more than one space, rendering with CoreText is different than freetype, kitty has much less control, it is up to CoreText to decide how to render the glyph.

Luflosi commented 5 years ago

I used three spaces on both sides but the first three and last two spaces don't do anything. Is there a way to change CoreText rendering to fill all available space (2 cells)? screenshot

kovidgoyal commented 5 years ago

Not that I know of, but it is a pretty simple function, try for yourself, look for render_glyphs in core_text.m. The rest of the kitty code should be passing in a width and height corresponding to two cells, the rest is up to CoreText.

Luflosi commented 5 years ago

This should theoretically be possible by adjusting the font size of private use unicode characters but I have no idea how to do that. Maybe someone else will try this in the future.

kovidgoyal commented 5 years ago

I dont really understand why we should need to do that. If CoreText decides to render characters from some font at a specified pt sz too small, that is a bug in CoreText and should be fixed there. Or CoreText is rendering as Apple wants it to, in which case we should not tamper with it artificially.

kovidgoyal commented 5 years ago

Did you confirm that kitty is passing in the correct width and height?

Luflosi commented 5 years ago

For the single cell, the size is 8x14 and for two cells it is 16x14, which should be correct. I used a digital magnifying glass to look at the pixels and the size of a cell is indeed 8x14 pixels. In a single cell, the character renders about as large as it can be with one pixel to spare for the width. The old patched font I used renders slightly differently and uses all eight pixels. I presume this is the correct size for the character. When rendering it in two cells, the font size stays the same and thus the character is rendered in exactly the same size. While this may be what Apple intends I would prefer a bigger size in this case. These private use unicode characters are usually little pictures which are a little harder to see/identify than normal english characters, maybe because the pictures tend to be more complex. See for example my git status line: (magnified) small font At this font size it is pretty much impossible to tell that the weird shape in front of the 1 is actually a star. This is what the whole thing looks like with a much bigger font size: (also magnified) big font This was just an example as there is no space behind that character anyways and even with a space it would not be rendered in two cells. But this applies to other characters too.

SolitudeSF commented 5 years ago

offtopic, but does anyone know if there is font thats just purely symbolic variant of nerd fonts, not patched onto another font?

kovidgoyal commented 5 years ago

yeah the 3270 font I referenced is pure symbols.

Luflosi commented 5 years ago

Well, there are also "normal" characters in that font but if it's not patched that's probably the closest to what @SolitudeSF wants.

hrqmonteiro commented 3 years ago

I have the same problem here, the nerd font glyphs in any font i set shows ridiculously small

Kitty: 2021-06-08_20-29

Alacritty: 2021-06-08_20-29_1

And i have the 3270 Nerd Font Installed, i set an unpatched version of the font i want (Victor Mono) and i still can't get the symbols to render correctly. Any solution?

If i do the kitty --debug-font-fallback all of the things i write say that DejaVu Sans Mono is the fallback.

daaannieeellll commented 9 months ago

I also just stumbled upon this problem while trying to use FiraCode Nerd Font Mono in the symbol_map. Switching to a non-mono font did the trick for me (in my case FiraCode Nerd Font). Might be worth a try if anyone's still facing this problem

Kjaer commented 2 weeks ago

I have been here like folks above too. Turns out Kitty was innocent. I am using JetBrains Mono Nerd font and in the readme file it says,

  • Pick your font family:
    • If you are limited to monospaced fonts (because of your terminal, etc) then pick a font with Nerd Font Mono (or NFM).
    • If you want to have bigger icons (usually around 1.5 normal letters wide) pick a font without Mono i.e. Nerd Font (or NF). Most terminals support this, but ymmv.
    • If you work in a proportional context (GUI elements or edit a presentation etc) pick a font with Nerd Font Propo (or NFP).

So I set font Family for kitty (I am using 0.36.0 at the moment) JetBrains Nerd Font Mono and set icons via symbol_map non-mono font.

Here is my respective kitty config:

# BEGIN_KITTY_FONTS
# Font ligatures settings for Jet Brains Mono Font:
# https://github.com/JetBrains/JetBrainsMono/wiki/OpenType-features
font_family             family="JetBrainsMono Nerd Font Mono" features="+zero +ss02 +cv04 +cv16 +cv18 +cv19 +cv20"
bold_font               auto
italic_font             auto
bold_italic_font        auto
font_size               18.0
modify_font cell_height 120%
# END_KITTY_FONTS

# BEGIN_KITTY_SYMBOL_MAPS
symbol_map U+E000-U+F1AF0 JetBrainsMonoNL Nerd Font
# END_KITTY_SYMBOL_MAPS

and glimpse of my terminal: Screenshot 2024-09-02 at 10 17 41