kovidgoyal / kitty

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

Italic font in tab truncated #1470

Closed rumpelsepp closed 5 years ago

rumpelsepp commented 5 years ago

The last p character is truncated in the tabs label. Is this related to #1442 or is this another issue? In vim it renders just fine.

last p is :truncated: screenshot

last p is fine: screenshot

edit: haha lol; typo in screenshot... :)

Luflosi commented 5 years ago

I'm pretty sure that it's related to that issue. Notice that all p characters in the first screenshot look identical and are all cut off. I think the text in the first screenshot is both italic and bold, while the second screenshot is only italic. That would explain why the text in the second screenshot is fine while the fist one is not.

rumpelsepp commented 5 years ago

I think the text in the first screenshot is both italic and bold, while the second screenshot is only italic.

might be. I did not realize, that both p are truncated. but your are right.

Luflosi commented 5 years ago

Actually there are three p. All look identical. This is because of how kitty works, it renders every character exactly once.

Luflosi commented 5 years ago

The m is also cut off.

rumpelsepp commented 5 years ago

yeah. Is this problem font specific? I use pretty much the default kitty settings in my arch:

$ kitty --debug-config
kitty 0.13.3 created by Kovid Goyal
Linux kronos 5.0.1-arch1-1-ARCH #1 SMP PREEMPT Sun Mar 10 10:55:53 UTC 2019 x86_64
Running under: Wayland
Arch Linux \r (\l)
Loaded config files: /home/rumpelsepp/.config/kitty/kitty.conf

Config options different from defaults:
shell fish
kovidgoyal commented 5 years ago

yeah it is font specific. If the bold/italic variant has different metrics than the normal then it wont fit in the cells and will get truncated. Either pick a monospaced font with correct metrics or turn off the bold/italic formatting for the active tab title in kitty.conf.

chrissimpkins commented 5 years ago

@kovidgoyal Kovid, Stefan poked us over in the Hack repository about this issue. Can you shed some light on the metrics concerns that you have here and how we might address them in the design? Thanks!

Associated IR on Hack repo: https://github.com/source-foundry/Hack/issues/480

kovidgoyal commented 5 years ago

The way font rendering works in kitty is that all characters are rendered exactly once. These characters are then simply displayed where-ever needed by the GPU. The screen in kitty is a grid of identically sized character cells.

The important part as far as this issue is concerned is that the size of the cell used to render characters is font-independent. It is calculated based on the metrics of the "regular" font. Bold and italic variants of the regular font are rendered in the same sized cell. This means that if a variant's characters dont fit within the same cell, they will be truncated.

This is why kitty works well only with monospaced fonts. It also requires the bold/italic variants of the font to have the same metric as the regular variant. Many monospace fonts manage to do that for most characters, some dont.

chrissimpkins commented 5 years ago

Thank you! We will take a look into this on our end. I appreciate your feedback here Kovid!

Frydac commented 2 years ago

Thank you for the explanation, too bad many popular fonts don't do this (FiraCode or Hack for example). They are rendered better in something like gVim or VSCode. Thanks to the ability to specify different fonts for italic it is luckily quite easy to still have your favorite font with bad metrics as regular font, and use something else that works for the italics, e.g. Source Code Pro has proper italics, and this is the nerd font patched version, and doesn't differ too much from FiraCode, but sometimes differing a lot looks nice.

font_family FiraCode Nerd Font Mono
italic_font SauceCodePro Nerd Font Mono

It might be nice, but probably a lot of work, to have the option to render fonts more cpu expensively and allow 'overlapping' characters.

EricDriussi commented 1 year ago

It might be nice, but probably a lot of work, to have the option to render fonts more cpu expensively and allow 'overlapping' characters.

I would greatly appreciate something like this, although I understand that might be too much work to be worth it.

Sleepful commented 1 year ago

Got here too. Here is my suggestion:

font_family Iosevka Nerd Font Medium
bold_font Iosevka Extrabold
italic_font Iosevka Nerd Font Medium Oblique
bold_italic_font Iosevka Nerd Font ExtraBold Oblique

It took a long time to find something that works, so enjoy!

themasugo commented 1 year ago

Yoy can try to fix the problem with this parameter too:

cell_width 110%