kovidgoyal / kitty

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

Variable fonts have thin weights in v0.34.0 #7361

Closed Scrumplex closed 3 weeks ago

Scrumplex commented 3 weeks ago

Describe the bug After updating to v0.34.0 the font weight of my terminal changed.

I bisected the git history between v0.34.0 and v0.33.1 and found d2c21ee2973ecda23825b8942989c11caa8193ff to be the culprit. If I revert that commit on top of v0.34.0 it returns to the previous rendering.

To Reproduce Steps to reproduce the behavior:

  1. Use font_family Fira Code (https://github.com/tonsky/FiraCode/releases/tag/6.2)
  2. Observe font rendering

Screenshots My config: Left is v0.34.0, right is v0.34.0 with the revert Kitty window with v0.34.0 exhibiting issue on the left, reverted commit on the right without the issue

NONE config: Left is v0.34.0, right is v0.34.0 with the revert Kitty window with v0.34.0 exhibiting issue on the left, reverted commit on the right without the issue

Environment details

kitty 0.34.0 created by Kovid Goyal
Linux andromeda 6.8.4-zen1 #1-NixOS ZEN SMP PREEMPT_DYNAMIC Tue Jan  1 00:00:00 UTC 1980 x86_64

<<< Welcome to NixOS 24.05.20240416.5672bc9 (x86_64) - /dev/tty >>>

Run 'nixos-help' for the NixOS manual.

DISTRIB_CODENAME=uakari
DISTRIB_DESCRIPTION="NixOS 24.05 (Uakari)"
DISTRIB_ID=nixos
DISTRIB_RELEASE="24.05"
LSB_VERSION="24.05 (Uakari)"
Running under: Wayland (sway version 1.10-dev) missing: blur
Frozen: False
Paths:
  kitty: /nix/store/ms4k2nl5xwfl5964rxpvczsyn09nslym-kitty-0.34.0/bin/kitty
  base dir: /nix/store/ms4k2nl5xwfl5964rxpvczsyn09nslym-kitty-0.34.0/lib/kitty
  extensions dir: /nix/store/ms4k2nl5xwfl5964rxpvczsyn09nslym-kitty-0.34.0/lib/kitty/kitty
  system shell: /run/current-system/sw/bin/fish
Loaded config files:
  /home/scrumplex/.config/kitty/kitty.conf

Config options different from defaults:
background_opacity      0.975
disable_ligatures       1
font_family             Fira Code
placement_strategy      top-left
shell_integration       frozenset({'no-rc', 'no-cursor'})
symbol_map:
    U+23fb - U+23fe → Symbols Nerd Font
    U+2500 - U+259f → Symbols Nerd Font
    U+2665 - U+2665 → Symbols Nerd Font
    U+26a1 - U+26a1 → Symbols Nerd Font
    U+e000 - U+e00a → Symbols Nerd Font
    U+e0a0 - U+e0a2 → Symbols Nerd Font
    U+e0a3 - U+e0a3 → Symbols Nerd Font
    U+e0b0 - U+e0b3 → Symbols Nerd Font
    U+e0b4 - U+e0c8 → Symbols Nerd Font
    U+e0ca - U+e0ca → Symbols Nerd Font
    U+e0cc - U+e0d4 → Symbols Nerd Font
    U+e200 - U+e2a9 → Symbols Nerd Font
    U+e300 - U+e3e3 → Symbols Nerd Font
    U+e5fa - U+e62c → Symbols Nerd Font
    U+e700 - U+e7c5 → Symbols Nerd Font
    U+ea60 - U+ebeb → Symbols Nerd Font
    U+eb58 - U+eb58 → Symbols Nerd Font
    U+f000 - U+f2e0 → Symbols Nerd Font
    U+f300 - U+f32f → Symbols Nerd Font
    U+f400 - U+f532 → Symbols Nerd Font
    U+e276c - U+e2771 → Symbols Nerd Font
    U+f0001 - U+f1af0 → Symbols Nerd Font
tab_bar_style           powerline
Colors:
    active_border_color     #b4befe   
    active_tab_background   #cba6f7   
    active_tab_foreground   #11111b   
    background              #1e1e2e   
    bell_border_color       #f9e2af   
    color0                  #45475a   
    color1                  #f38ba8   
    color10                 #a6e3a1   
    color11                 #f9e2af   
    color12                 #89b4fa   
    color13                 #f5c2e7   
    color14                 #94e2d5   
    color15                 #a6adc8   
    color2                  #a6e3a1   
    color3                  #f9e2af   
    color4                  #89b4fa   
    color5                  #f5c2e7   
    color6                  #94e2d5   
    color7                  #bac2de   
    color8                  #585b70   
    color9                  #f38ba8   
    cursor                  #f5e0dc   
    cursor_text_color       #1e1e2e   
    foreground              #cdd6f4   
    inactive_border_color   #6c7086   
    inactive_tab_background #181825   
    inactive_tab_foreground #cdd6f4   
    mark1_background        #b4befe   
    mark1_foreground        #1e1e2e   
    mark2_background        #cba6f7   
    mark2_foreground        #1e1e2e   
    mark3_background        #74c7ec   
    mark3_foreground        #1e1e2e   
    selection_background    #f5e0dc   
    selection_foreground    #1e1e2e   
    tab_bar_background      #11111b   
    url_color               #f5e0dc   

Important environment variables seen by the kitty process:
    PATH                                /nix/store/ms4k2nl5xwfl5964rxpvczsyn09nslym-kitty-0.34.0/bin:/nix/store/32hx7y3vn8l5wvpzw7jgradnxnlsb6y2-imagemagick-7.1.1-29/bin:/nix/store/2nhjsfc4pg74vqnsbjmnpi7359y6f3wi-ncurses-6.4-dev/bin:/run/wrappers/bin:/home/scrumplex/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/home/scrumplex/.nix-profile/bin:/nix/profile/bin:/home/scrumplex/.local/state/nix/profile/bin:/etc/profiles/per-user/scrumplex/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
    LANG                                en_IE.UTF-8
    EDITOR                              nvim
    SHELL                               /run/current-system/sw/bin/fish
    DISPLAY                             :0
    WAYLAND_DISPLAY                     wayland-1
    USER                                scrumplex
    XCURSOR_SIZE                        24
    XDG_CONFIG_DIRS                     /etc/xdg:/home/scrumplex/.local/share/flatpak/exports/etc/xdg:/var/lib/flatpak/exports/etc/xdg:/home/scrumplex/.nix-profile/etc/xdg:/nix/profile/etc/xdg:/home/scrumplex/.local/state/nix/profile/etc/xdg:/etc/profiles/per-user/scrumplex/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg
    XDG_DATA_HOME                       /home/scrumplex/.local/share
    XDG_CONFIG_HOME                     /home/scrumplex/.config
    XDG_SEAT                            seat0
    XDG_VIDEOS_DIR                      /home/scrumplex/Videos
    XDG_SESSION_TYPE                    wayland
    XDG_PICTURES_DIR                    /home/scrumplex/Pictures
    XDG_PUBLICSHARE_DIR                 /home/scrumplex/Public
    XDG_CURRENT_DESKTOP                 sway
    XDG_DOWNLOAD_DIR                    /home/scrumplex/Downloads
    XDG_MUSIC_DIR                       /home/scrumplex/Music
    XDG_TEMPLATES_DIR                   /home/scrumplex/Templates
    XDG_CACHE_HOME                      /home/scrumplex/.cache
    XDG_SESSION_CLASS                   user
    XDG_DESKTOP_DIR                     /home/scrumplex/Desktop
    XDG_VTNR                            1
    XDG_SESSION_ID                      1
    XDG_STATE_HOME                      /home/scrumplex/.local/state
    XDG_RUNTIME_DIR                     /run/user/1000
    XDG_DOCUMENTS_DIR                   /home/scrumplex/Documents
    XDG_DATA_DIRS                       /nix/store/jh4q17qfp1lgz5cr2dj3m9fn9sm16345-sway-+087226d/share:/nix/store/glky0wjlb1jc81awd8ddajr4fay1w27w-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0:/nix/store/207cqakykajjglbs6mwrprijwkanhnzz-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41:/home/scrumplex/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/home/scrumplex/.nix-profile/share:/nix/profile/share:/home/scrumplex/.local/state/nix/profile/share:/etc/profiles/per-user/scrumplex/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

Additional context I was able to reproduce this with an empty kitty config

Scrumplex commented 3 weeks ago

I additionally have this local fontconfig config:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
  <family>Fira Code</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>

<alias>
  <family>Fira Code,Fira Code Light</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>

<alias>
  <family>Fira Code,Fira Code Medium</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>

<alias>
  <family>Fira Code,Fira Code Retina</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>

<alias>
  <family>Fira Code,Fira Code SemiBold</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>

<alias>
  <family>Monocraft</family>
  <prefer><family>Symbols Nerd Font</family></prefer>
</alias>
</fontconfig>
kovidgoyal commented 3 weeks ago

The commit is correct as far as I can see, change your font family to fira code medium or fira code retina or whichever variant has the weight you like. Not sure why you are aliasing fira code to nerd font though.

Scrumplex commented 3 weeks ago

It doesn't seem like any of the Fira Code variations seem to change this behavior at all.

These are the fonts in question here:

$ fc-list | grep "Fira Code"
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light:style=SemiBold
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light:style=Light,Regular
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light:style=Bold
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light:style=Medium
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light:style=Regular
/nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf: Fira Code,Fira Code Light

I also tried setting font_family Fira Code Light:style=Medium and even Bold with no change at all.

Not sure why you are aliasing fira code to nerd font though.

I use that to support Nerd Font Symbols without using a patched font in applications that don't have a feature like Kitty's symbol_map. Aliasing it like that makes fontconfig prefer nerd-fonts symbols where applicable (where NF Symbols has a glyph for a certain codepoint) while using Fira Code for anything else. This is basically the same thing as the upstream fc config: https://github.com/ryanoasis/nerd-fonts/blob/master/10-nerd-font-symbols.conf

kovidgoyal commented 3 weeks ago

Use

font_family Fira Code Light

Then run kitty with --debug-font-fallback and post the output

Repeat with

font_family Fira Code

Scrumplex commented 3 weeks ago
$ cat fira-code.conf
font_family Fira Code

$ kitty --config fira-code.conf --debug-font-fallback
[0.050] Preloaded font faces:
[0.050] normal face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.050] bold face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.050] italic face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.050] bi face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0

$ cat fira-code-light.conf
font_family Fira Code Light

$ kitty --config fira-code-light.conf --debug-font-fallback
[0.049] Preloaded font faces:
[0.049] normal face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.049] bold face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.049] italic face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
[0.049] bi face: /nix/store/fbb5h6yk4gallrfqh8770m28dymz4pzw-fira-code-6.2/share/fonts/truetype/FiraCode-VF.ttf:0
kovidgoyal commented 3 weeks ago

OK, that's strange I will take a look when I have a minute.

kovidgoyal commented 3 weeks ago

Well, looks like fontconfig is overloading index to also contain variable font data in the upper 16 bits, sigh. And there is no way to match variable fonts in kitty. Someday I might add support for it, but in the meantime I suggest just uninstalling the variable variant (the one with VF in the filename) or masking it in your fontconfig.

See #3711