Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small sized nerdfont symbols #1463

Closed
mmequignon opened this issue Mar 13, 2019 · 31 comments
Closed

Small sized nerdfont symbols #1463

mmequignon opened this issue Mar 13, 2019 · 31 comments

Comments

@mmequignon
Copy link

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
Copy link
Contributor

Luflosi commented Mar 13, 2019

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

@kovidgoyal
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Author

mmequignon commented Mar 14, 2019

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
Copy link
Owner

yes, like this:

Screenshot_20190314_063520

@kovidgoyal
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Author

mmequignon commented Mar 14, 2019

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
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

For me it's MesloLGM Nerd Font Mono.

@kovidgoyal
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Author

mmequignon commented Mar 14, 2019

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

@kovidgoyal
Copy link
Owner

kovidgoyal commented Mar 14, 2019 via email

@mmequignon
Copy link
Author

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

@Luflosi
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Owner

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
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Owner

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
Copy link
Owner

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

@Luflosi
Copy link
Contributor

Luflosi commented Mar 14, 2019

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
Copy link
Contributor

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

@kovidgoyal
Copy link
Owner

yeah the 3270 font I referenced is pure symbols.

@Luflosi
Copy link
Contributor

Luflosi commented Mar 15, 2019

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
Copy link

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
Copy link

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

ernestre added a commit to ernestre/dotfiles that referenced this issue Aug 28, 2024
@Kjaer
Copy link

Kjaer commented Sep 2, 2024

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

@UncleGravity
Copy link

This has been bugging me for weeks and this finally solved it, thanks @Kjaer.

@Kjaer
Copy link

Kjaer commented Oct 25, 2024

I am glad I am be of help! But my settings above unfortunately overwrites emoji glyphs. So here is the new complete settings I have:

# 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' style=Light features='+zero +ss02 +cv04 +cv16 +cv18 +cv19 +cv20'
bold_font        family='JetBrainsMono Nerd Font Mono' style=Bold features='+zero +ss02 +cv04 +cv16 +cv18 +cv19 +cv20'
italic_font      family='JetBrainsMono Nerd Font Mono' style='Light Italic' features='+zero +ss02 +cv04 +cv16 +cv18 +cv19 +cv20'
bold_italic_font family='JetBrainsMono Nerd Font Mono' style='Bold Italic' features='+zero +ss02 +cv04 +cv16 +cv18 +cv19 +cv20'
font_size        15.0
modify_font cell_height 120%
# END_KITTY_FONTS


# BEGIN_KITTY_SYMBOL_MAPS
symbol_map U+E000-U+F8FF,U+F0000-U+FFFFF,U+100000-U+10ffff JetBrainsMonoNL Nerd Font
# END_KITTY_SYMBOL_MAPS

I took these glyph range from nerd fonts readme: https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points#overview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants