kovidgoyal / kitty

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

`kitty` sometimes doesn't load font specified by `font_family` #4085

Closed envp closed 3 years ago

envp commented 3 years ago

Describe the bug kitty doesn't load font specified by font_family in kitty.conf, unless provided as an override on the CLI (but still complains about not being able to find it, despite loading it)

To Reproduce Steps to reproduce the behavior:

  1. Change font_family IosevkaNerdFontCompleteM-Term, or font_family Iosevka Nerd Font Mono Regular in kitty.conf
  2. Reload preferences ( +,)
  3. kitty defaults to OS monospace font (Menlo in my case), expected it to load the specified font

Environment details

kitty 0.23.1 created by Kovid Goyal
Darwin C02Y80QCJGH5 19.6.0 Darwin Kernel Version 19.6.0: Tue Aug 24 20:28:00 PDT 2021; root:xnu-6153.141.40~1/RELEASE_X86_64 x86_64
ProductName:    Mac OS X ProductVersion:    10.15.7 BuildVersion:   19H1417
Loaded config files:
  /Users/envp/.config/kitty/kitty.conf

Config options different from defaults:
font_family          Iosevka Nerd Font Mono Regular
font_size            16.0
macos_thicken_font   0.5
tab_activity_symbol  !
tab_bar_min_tabs     1
tab_bar_style        powerline
tab_title_template   {index}: {title}
Added shortcuts:
    alt+1 KeyAction('disable_ligatures_in', ('active', 'always'))
    alt+2 KeyAction('disable_ligatures_in', ('all', 'never'))
    alt+3 KeyAction('disable_ligatures_in', ('tab', 'cursor'))
Colors:
    background           #000a00   
    color0               #2e3436   
    color1               #cc0000   
    color10              #8ae234   
    color11              #fce94f   
    color12              #729fcf   
    color13              #ad7fa8   
    color14              #34e2e2   
    color15              #eeeeec   
    color2               #4e9a06   
    color3               #c4a000   
    color4               #3465a4   
    color5               #75507b   
    color6               #06989a   
    color7               #d3d7cf   
    color8               #555753   
    color9               #ef2929   
    cursor               #bbbbbb   
    foreground           #eeeeec   
    selection_background #b4d5ff   
    selection_foreground #300a24   

Additional context Output of kitty +list-fonts --psnames | grep -i iosevka

Running kitty --config NONE -o font_family='Iosevka Nerd Font Mono Regular' does the following (unexpected things):

Kitty says the font isn't found.

$ kitty --config NONE -o font_family='Iosevka Nerd Font Mono Regular' -o font_size=20
[274 16:31:03.303503] The font Iosevka Nerd Font Mono Regular was not found, falling back to Menlo
[274 16:31:03.303553] The font Iosevka Nerd Font Mono Regular was not found, falling back to Menlo
[274 16:31:03.303579] The font Iosevka Nerd Font Mono Regular was not found, falling back to Menlo

But the newly opened child window uses Iosevka.

Additionally, kitty --config NONE uses Menlo as expected

Resolution:

User must quit kitty. In my case the default behaviour of macOS is not to quit on close, this is OS dependent and not a bug in kitty.

kovidgoyal commented 3 years ago

https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font

And there is no need to use patched fonts in kitty, in fact, you should not use them as patching often breaks fonts. Instead use https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.symbol_map with the nerd fonts installed as a standalone font.

envp commented 3 years ago

Thanks for the response, but the issue persists after switching to the unpatched font (installed per instructions here: https://github.com/be5invis/Iosevka)

I confirmed that both Iosevka Fixed, and Iosevka Term both show up in fontconfig like so:

fc-list : family spacing outline scalable | grep -e spacing=100 -e spacing=90 | grep -e outline=True | grep -e scalable=True | grep -i iosevka
...
Iosevka Fixed:spacing=100:outline=True:scalable=True
...
Iosevka Term:spacing=100:outline=True:scalable=True
...

and also in kitty +list-fonts.

As I understand it, it this is unexpected behaviour from kitty, and the issue still exists (also happens with other unpatched fonts such as 'IBM Plex Mono')

kovidgoyal commented 3 years ago

Works fine for me:

kitty --config NONE -o 'font_family Iosevka Term' --debug-font-fallback                                                              
[276 07:09:26.694468] Preloaded font faces:
[276 07:09:26.694501] normal face: /usr/share/fonts/TTF/iosevka-regular.ttc:1
[276 07:09:26.694511] bold face: /usr/share/fonts/TTF/iosevka-bold.ttc:1
[276 07:09:26.694519] italic face: /usr/share/fonts/TTF/iosevka-regular.ttc:9
[276 07:09:26.694527] bi face: /usr/share/fonts/TTF/iosevka-bold.ttc:9
envp commented 3 years ago

Works fine for me:

kitty --config NONE -o 'font_family Iosevka Term' --debug-font-fallback                                                              
[276 07:09:26.694468] Preloaded font faces:
[276 07:09:26.694501] normal face: /usr/share/fonts/TTF/iosevka-regular.ttc:1
[276 07:09:26.694511] bold face: /usr/share/fonts/TTF/iosevka-bold.ttc:1
[276 07:09:26.694519] italic face: /usr/share/fonts/TTF/iosevka-regular.ttc:9
[276 07:09:26.694527] bi face: /usr/share/fonts/TTF/iosevka-bold.ttc:9

Yeah, launching it as a child process works fine for me as well. What I meant was, when I launch it through the system launcher it doesn't pick up the font in the config, any reason you'd expect them to behave differently (and how would one go about debugging this)?

kovidgoyal commented 3 years ago

Presumably your system launcher is either launching kitty with a different set of env vars or a different kitty, if you have multiple ones installed on your system. I have no clue how to debug your system launcher, presumably look for its log files if any and figure out what its doing.

envp commented 3 years ago

Presumably your system launcher is either launching kitty with a different set of env vars or a different kitty, if you have multiple ones installed on your system. I have no clue how to debug your system launcher, presumably look for its log files if any and figure out what its doing.

To clarify, I have a single installation of kitty from brew, which is I why I think the issue is with kitty. If I change the font to e.g. Fantasque Sans Mono it loads the correct font (on startup, as well as on change), this only happens with some fonts.

envp commented 3 years ago

I'll try the curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin from docs and get back on this issue.

envp commented 3 years ago

I'll try the curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin from docs and get back on this issue.

Issue persists with a binary install as well.

kovidgoyal commented 3 years ago

There are no env vars that will affect some fonts and not others. One or more of your assumptions is incorrect, figure out which one.

weeebdev commented 2 years ago

Have you resolved this one? @envp

weeebdev commented 2 years ago

@kovidgoyal still, it shows me Symbol map: Symbols Nerd Font is invalid, ignoring even though it's present

kovidgoyal commented 2 years ago

Read the FAQ

weeebdev commented 2 years ago

Read the FAQ

I did it as it was suggested in the FAQ. Here is the config.

image

And here is the output

image

Separate symbols font and not patched font. Symbols are broken and show something in chinese

image
kovidgoyal commented 2 years ago

Read the FAQ again, in particular focus on the syntax for symbol_map

weeebdev commented 2 years ago

Read the FAQ again, in particular focus on the syntax for symbol_map

Oh, got it. So I must specify the codepoints. Thanks!

envp commented 2 years ago

There are no env vars that will affect some fonts and not others. One or more of your assumptions is incorrect, figure out which one.

Apologies for the notification on a closed issue, but the resolution in my case turned out to be the macOS process lingering. I did not explicitly quit (Cmd + Q) kitty, which is the root cause. I've edited the issue description with what resolved the issue in my case.

Is it possible to mark this under some kind of user-error label?