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

list-fonts does not show Fira Code #827

Closed
utdemir opened this issue Aug 26, 2018 · 27 comments
Closed

list-fonts does not show Fira Code #827

utdemir opened this issue Aug 26, 2018 · 27 comments

Comments

@utdemir
Copy link

utdemir commented Aug 26, 2018

Hello.

I'm trying to use "Fira Code" font with Kitty. I installed it with my OS's package manager, and now fontconfig sees it, but kitty doesn't.

I read many relevant issues, and they were mostly about the font not being monospaced. But, as far as I know Fira Code is monospaced and fontconfig shows the spacing as 100.

I am not very familiar with how fonts work, so probably I'm wrong somewhere; can you tell me what else should I do before I can use Fira Code with kitty?

$ fc-list : family spacing | grep -i fira
Fira Code:spacing=100
Fira Code,Fira Code Retina:spacing=100
Fira Code,Fira Code Medium:spacing=100
Fira Code,Fira Code Light:spacing=100
$ kitty list-fonts
DejaVu Sans Mono
    DejaVu Sans Mono
    DejaVu Sans Mono Bold
.... # no Fira Code
$ kitty --version
kitty 0.11.2 created by Kovid Goyal
@utdemir utdemir changed the title list-fonts does not show FiraCode list-fonts does not show Fira Code Aug 26, 2018
@maximbaz
Copy link
Contributor

I'm using Fira Code, so at least I can assure you that it is supposed to work. In my case I defined it to be my default monospace font, so I don't actually have anything in kitty's config about font families at all.

❯ kitty list-fonts                       
...
Fira Code
    Fira Code Bold
    Fira Code Light
    Fira Code Medium
    Fira Code Regular
    Fira Code Retina
...

Try rebooting maybe? 🙂

@kovidgoyal
Copy link
Owner

Fira Code works out of the box with kitty (it is the font I used to develop kitty's ligature support and is even included in its test suite). You might need to re-build your fontconfig caches, and/or reboot to make sure the font is available.

@utdemir
Copy link
Author

utdemir commented Aug 26, 2018

Thank you for your quick answer.

I both re-built the fontconfig caches and rebooted my computer. I even set "Fira Code" as the default monospace font on my system as what @maximbaz said. So now when I open other applications(eg leafpad) they use "Fira Code" by default successfully. However kitty neither shows it on list-fonts or uses it by default.

As I said, I'm sure there's something strange with my system; however since the other applications can see and use the font I'm assuming there is something different with the way kitty finds the fonts, and I'm just asking if there's anything I should pay attention differently to use it in kitty.

@kovidgoyal
Copy link
Owner

Nope kitty just uses fontconfig to load fonts, which is what the vast majority of applications on linux systems use. Are you sure kitty is not using Fira Code? Run it with --debug-font-fallback to check

@utdemir
Copy link
Author

utdemir commented Aug 26, 2018

It does not look like "Fira Code", and --debug-font-fallback says it's using DejaVu:

$ kitty --debug-config
kitty 0.11.2 created by Kovid Goyal
Linux serenity 4.14.66 #1-NixOS SMP Wed Aug 22 05:46:11 UTC 2018 x86_64
Running under: X11
<<< Welcome to NixOS 18.03.133157.fde20125199 (\m) - \l >>>

Run `nixos-help` for the NixOS manual.
Loaded config files: /home/utdemir/.config/kitty/kitty.conf

Config options different from defaults:
clear_all_shortcuts True
font_family         Fira Code
font_size           9.0
scrollback_lines    100000
Added shortcuts:
...
$ kitty --debug-font-fallback
[239 00:26:16.175059] Preloaded font faces:
[239 00:26:16.175107] normal face: /nix/store/95aj70d0xhsicmv0w9fmgkdqi1r37n08-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSansMono.ttf:0
[239 00:26:16.175146] bold face: /nix/store/95aj70d0xhsicmv0w9fmgkdqi1r37n08-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSansMono-Bold.ttf:0
[239 00:26:16.175184] italic face: /nix/store/95aj70d0xhsicmv0w9fmgkdqi1r37n08-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSansMono-Oblique.ttf:0
[239 00:26:16.175213] bi face: /nix/store/95aj70d0xhsicmv0w9fmgkdqi1r37n08-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSansMono-BoldOblique.ttf:0
[239 00:26:16.430682] Ignoring resize request for tiny size: 0x0

@kovidgoyal
Copy link
Owner

And what's the output of

kitty --debug-config

@utdemir
Copy link
Author

utdemir commented Aug 26, 2018

Here:

$ kitty --debug-config
kitty 0.11.2 created by Kovid Goyal
Linux serenity 4.14.66 #1-NixOS SMP Wed Aug 22 05:46:11 UTC 2018 x86_64
Running under: X11
<<< Welcome to NixOS 18.03.133157.fde20125199 (\m) - \l >>>

Run `nixos-help` for the NixOS manual.
Loaded config files: /home/utdemir/.config/kitty/kitty.conf

Config options different from defaults:
clear_all_shortcuts True
font_family         Fira Code
font_size           9.0
scrollback_lines    100000
Added shortcuts:
         shift+control+p KeyAction(func='kitten', args=['hints', '--type path --program -'])
Removed shortcuts:
         shift+insert KeyAction(func='paste_from_selection', args=())
         shift+control+comma KeyAction(func='move_tab_backward', args=())
         shift+control+period KeyAction(func='move_tab_forward', args=())
         shift+control+1 KeyAction(func='first_window', args=())
         shift+control+2 KeyAction(func='second_window', args=())
         shift+control+3 KeyAction(func='third_window', args=())
         shift+control+4 KeyAction(func='fourth_window', args=())
         shift+control+5 KeyAction(func='fifth_window', args=())
         shift+control+6 KeyAction(func='sixth_window', args=())
         shift+control+7 KeyAction(func='seventh_window', args=())
         shift+control+8 KeyAction(func='eighth_window', args=())
         shift+control+9 KeyAction(func='ninth_window', args=())
         shift+control+a > 1 KeyAction(func='set_background_opacity', args=['1'])
         shift+control+a > d KeyAction(func='set_background_opacity', args=['default'])
         shift+control+a > l KeyAction(func='set_background_opacity', args=['-0.1'])
         shift+control+a > m KeyAction(func='set_background_opacity', args=['+0.1'])
         shift+control+b KeyAction(func='move_window_backward', args=())
         shift+control+e KeyAction(func='kitten', args=['hints'])
         shift+control+f KeyAction(func='move_window_forward', args=())
         shift+control+j KeyAction(func='scroll_line_down', args=())
         shift+control+k KeyAction(func='scroll_line_up', args=())
         shift+control+n KeyAction(func='new_os_window', args=())
         shift+control+o KeyAction(func='pass_selection_to_program', args=())
         shift+control+p > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
         shift+control+p > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
         shift+control+p > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
         shift+control+p > w KeyAction(func='kitten', args=['hints', '--type word --program -'])
         shift+control+p > shift+f KeyAction(func='kitten', args=['hints', '--type path'])
         shift+control+q KeyAction(func='close_tab', args=())
         shift+control+r KeyAction(func='start_resizing_window', args=())
         shift+control+s KeyAction(func='paste_from_selection', args=())
         shift+control+t KeyAction(func='new_tab', args=())
         shift+control+w KeyAction(func='close_window', args=())
         shift+control+left_bracket KeyAction(func='previous_window', args=())
         shift+control+right_bracket KeyAction(func='next_window', args=())
         shift+control+grave_accent KeyAction(func='move_window_to_top', args=())
         shift+control+escape KeyAction(func='kitty_shell', args=['window'])
         shift+control+enter KeyAction(func='new_window', args=())
         shift+control+backspace KeyAction(func='change_font_size', args=[True, None, 0.0])
         shift+control+right KeyAction(func='next_tab', args=())
         shift+control+left KeyAction(func='previous_tab', args=())
         shift+control+down KeyAction(func='scroll_line_down', args=())
         shift+control+up KeyAction(func='scroll_line_up', args=())
         shift+control+page_up KeyAction(func='scroll_page_up', args=())
         shift+control+page_down KeyAction(func='scroll_page_down', args=())
         shift+control+home KeyAction(func='scroll_home', args=())
         shift+control+end KeyAction(func='scroll_end', args=())
         shift+control+f2 KeyAction(func='edit_config_file', args=())
         shift+control+f11 KeyAction(func='toggle_fullscreen', args=())
         shift+control+alt+t KeyAction(func='set_tab_title', args=())
Changed shortcuts:
         shift+control+0 KeyAction(func='change_font_size', args=[True, None, 0.0])
         shift+control+h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
         shift+control+l KeyAction(func='show_scrollback', args=())
         shift+control+u KeyAction(func='kitten', args=['hints'])
$ cat ~/.config/kitty/kitty.conf 
scrollback_lines 100000

font_size 9
font_family      Fira Code
bold_font        auto
italic_font      auto
bold_italic_font auto

clear_all_shortcuts yes

map ctrl+shift+c copy_to_clipboard
map ctrl+shift+v paste_from_clipboard
map ctrl+shift+l show_scrollback

map ctrl+shift+u kitten hints
map ctrl+shift+p kitten hints --type path --program -
map ctrl+shift+h kitten hints --type hash --program -

map ctrl+shift+equal change_font_size all +2.0
map ctrl+shift+minus change_font_size all -2.0
map ctrl+shift+0 change_font_size all 0

@kovidgoyal
Copy link
Owner

kovidgoyal commented Aug 26, 2018

You want

font_family FiraCode-Regular

or if you have made it the default monosspace font

font_family monospace

That should workaround list-fonts not being able to find it.

@utdemir
Copy link
Author

utdemir commented Aug 26, 2018

Thank you, I tried both of your suggestions, but they did not help. It still uses DejaVu and --debug-font-fallback output is the same.

I also confirmed that the issue is only with Fira Code, I just tried switching to Ubuntu Mono and it worked.

@kovidgoyal
Copy link
Owner

Sorry then I am out of ideas, your best bet is to debug the code. Font selection code in linux happens in get_font_files() function in fontconfig.c

@utdemir
Copy link
Author

utdemir commented Aug 27, 2018

Thank you for all your ideas @kovidgoyal , and thank you for maintaining Kitty :). I'll take a look at the code then.

Have a nice day.

@magnetophon
Copy link

FWIW:
I'm having the same issue.
Also on NixOS.

@utdemir
Copy link
Author

utdemir commented Aug 30, 2018

I worked around the issue by creating a ~/.local/share/fonts folder and putting the otf files inside. For some reason kitty does not read fonts in ~/.nix-profile/share/fonts even if they're found by fontconfig. Symlinking those fonts to ~/.local/share/fonts also work.

cc @magnetophon

@kovidgoyal
Copy link
Owner

This will be because font config on NixOS is broken. Probably there are multiple fonts.conf files and depending on how fontconfig is initialized/invoked it reads different ones. See for example: NixOS/nixpkgs#8318

@utdemir
Copy link
Author

utdemir commented Aug 30, 2018

Thank you @kovidgoyal for all your help!

I'll follow up from that issue.

Have a nice day, and thank you for creating kitty!

@nkoehring
Copy link

I'm having the same issue but cannot fix it with the suggested methods. My font of choice is the nerdfont version of Monofur and it is situated in ~/.local/share/fonts, found by fc-list, not found by kitty list-fonts but interestingly shown by kitty --debug-font-fallback for some Unicode character:

[256 21:29:18.620815] normal face: /usr/share/fonts/TTF/DejaVuSansMono.ttf:0
[256 21:29:18.620826] bold face: /usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf:0
[256 21:29:18.620836] italic face: /usr/share/fonts/TTF/DejaVuSansMono-Oblique.ttf:0
[256 21:29:18.620865] bi face: /usr/share/fonts/TTF/DejaVuSansMono-BoldOblique.ttf:0
U+e0b1 Face(family=Monofur Nerd Font Mono, style=Book, ps_name=MonofurNerdFontCompleteM-, path=/home/nk/.local/share/fonts/monofur Nerd Font Complete Mono.ttf, index=0, is_scalable=True, has_color=False, ascender=1952, descender=-452, height=2404, underline_position=-450, underline_thickness=150) (new face)

My config has only font_family Monofur Nerd Font Mono:

kitty 0.12.1 created by Kovid Goyal                                                                                                                                             Linux nkwd 4.18.2_1 #1 SMP PREEMPT Sat Aug 18 03:34:03 UTC 2018 x86_64                                                                                                          Running under: X11                                                                                                                                                              Void \r (\n) (\l)                                                                                                                                                               
Loaded config files: /home/nk/.config/kitty/kitty.conf                                                                                                                                                                                                                                                                                                          
Config options different from defaults:                                                                                                                                         background            Color(red=56, green=56, blue=56)                                                                                                                          
click_interval        0.3                                                                                                                                                       copy_on_select        True                                                                                                                                                      
cursor                Color(red=136, green=136, blue=136)                                                                                                                       cursor_text_color     None                                                                                                                                                      
dim_opacity           0.8                                                                                                                                                       enable_audio_bell     False                                                                                                                                                     
enabled_layouts       ['tall:bias=60', 'fat:bias=70', 'stack']                                                                                                                  focus_follows_mouse   True                                                                                                                                                      
font_family           Monofur Nerd Font Mono                                                                                                                                    foreground            Color(red=220, green=220, blue=204)                                                                                                                       
inactive_text_alpha   0.8                                                                                                                                                       initial_window_height (40, 'cells')                                                                                                                                             
initial_window_width  (90, 'cells')                                                                                                                                             mouse_hide_wait       2.0                                                                                                                                                       
remember_window_size  False                                                                                                                                                     repaint_delay         16                                                                                                                                                        
tab_fade              (0.2, 0.5, 0.8, 1.0)                                                                                                                                      visual_bell_duration  0.1                                                                                                                                                       
window_padding_width  4.0

The situation doesn't change when I set MonofurNerdFontMono-Book in the config instead. I'm using the font in st, where it is configured as

static char *font = "monofur Nerd Font Mono:pixelsize=28:antialias=true:autohint=true";

@kovidgoyal
Copy link
Owner

The font has to be monospaced, that is have a spacing of 100 in fontconfig, to be useable as the main font in kitty.

@mister-walter
Copy link

Note that there is currently an issue with the Nerd Font patcher (ryanoasis/nerd-fonts#270) that causes their patched fonts to fail to be identified as monospace (and thus they don't show up in the output of kitty list-fonts).

If you want to use a Nerd Font patched font, you should use an older version of their patched fonts. Per a suggestion in the linked issue, I'm using v1.2 without issue.

@iderik
Copy link

iderik commented Nov 11, 2018

Ive been trying to convert a font from pcf to ttf, but list-fonts aint accepting the font. The font works fine in Sublime text editor. fc-list says "spacing: 100". It has embedded bitmaps.

[idk@stn ~]$ fc-list -v kiss
Pattern has 26 elts (size 32)
        family: "kiss"(s)
        familylang: "en"(s)
        style: "Medium"(s)
        stylelang: "en"(s)
        fullname: "kuk"(s)
        fullnamelang: "en"(s)
        slant: 0(i)(s)
        weight: 100(f)(s)
        width: 100(f)(s)
        pixelsize: 16(f)(s)
        spacing: 100(i)(s)
        foundry: "PfEd"(s)
        antialias: False(s)
        file: "/home/idk/.local/share/fonts/bajs.ttf"(s)
        index: 0(i)(s)
        outline: False(s)
        scalable: False(s)
        charset: 
        0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
        0001: ffffffff ffffffff ffffffff ff3fffff 6005c040 00800000 00000000 00000000
        0002: 0f000000 008c0000 0b100000 00040000 00040000 38000000 3b0000c0 00000000
        0003: 00001dff 00000200 00000000 00000000 ffffd7f0 fffffffb 00227fff 007f0000
        0004: ffffffff ffffffff ffffffff 00000c0c 3fff0000 0fcfcc3f ffff8007 033ffffc
        001e: 00003000 00f00000 000000ff 00003000 00000000 33000000 00003c00 03000030
        0020: ffffffff 560d0047 00000000 fff30000 05ff7fff 00005080 00000000 00000000
        0021: 2460c004 00200054 00000000 00000000 003f0000 08200150 003f1800 00000000
        0022: c67c3ff9 000007a0 00000100 00000c33 000000cc 00000020 0000000c 00000000
        0023: 02010f05 00000003 00000000 00000000 f8000000 3c00fbff 00010000 00000000
        0024: 00003e00 00000010 00000000 00000000 00000000 00000000 00000000 00000000
        0025: ffffff0f ffffffff ffff0fff ffffffff ffcfffff 10445001 03008c41 00000000
        0026: 00000000 1c000000 00000005 00000c69 00000000 00000000 00000000 00000000
        0027: 01980000 00000000 00000000 00000000 00000000 00000000 00000000 00000f00
        0028: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
        002e: 00000000 00001000 00000000 00000000 00000000 00000000 00000000 00000000
        00e0: 00000000 00000000 00000000 00000000 00000000 000f0007 00000000 00000000
        00f6: 00000000 00000000 00000000 00000000 00000000 40000000 00000000 00000000
        00ff: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 20000000
(s)
        lang: aa|af|av|ay|az-az|ba|bm|be|bg|bi|bin|br|bs|bua|ca|ce|ch|chm|co|cs|cv|da|de|el|en|eo|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gn|gv|haw|ho|hr|hu|ia|ig|id|ie|ik|io|is|it|kaa|ki|kk|kl|kum|kv|kw|ky|la|lb|lez|ln|lt|lv|mg|mh|mi|mk|mo|mt|nb|nds|nl|nn|no|nr|nso|ny|oc|om|os|pl|pt|rm|ro|ru|sah|se|sel|sh|sk|sl|sm|sma|smj|smn|so|sq|sr|ss|st|sv|sw|tg|tk|tl|tn|to|tr|ts|tt|tw|tyv|uk|uz|vo|vot|wa|wen|wo|xh|yap|zu|ak|an|crh|csb|fat|fil|hsb|ht|jv|kj|ku-tr|kwm|lg|li|mn-mn|ms|na|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|ty|za(s)
        fontversion: 65536(i)(s)
        fontformat: "TrueType"(s)
        decorative: False(s)
        postscriptname: "bajs"(s)
        color: False(s)
        symbol: False(s)
        variable: False(s)

Ive also tried to read the sources of Kitty, to find out why the font was rejected, but its too hard for me to understand. Is there anything else than FC_SPACING that is used?

Is it possible to have more detailed debug output then debug-config and debug-fallback-font?

@kovidgoyal
Copy link
Owner

kitty requires scalable fonts for its main font. fontconfig thinks your font is not scalable, see the line:

[code]
scalable: False(s)
[/code]

in the fontconfig output.

@iderik
Copy link

iderik commented Nov 12, 2018

Thanks, @kovidgoyal . Its working now.

@frabjous
Copy link

On ArchLinux, Fira Code no longer works with kitty since the recent upgrade to version 2-1 of the ttf-fira-code and otf-fira-code packages. They don't show up with kitty list-fonts. I tried installing the fonts directly from the FiraCode git repository, and that did not work either. I take it this is because fc-list -v "Fira Code" | grep spacing | head -n 1 is giving the spacing as "90(i)(s)" rather than "100(i)(s)". Downgrading to the older package otf-fira-code 1-207 solves this. Is this a bug I should report on the Fira Code site?

@nkoehring
Copy link

nkoehring commented Sep 16, 2019

@frabjous yes, that's certainly a problem on the fonts side. Although it might be a feature rather than a bug because spacing=90 stands for dual.

@Luflosi
Copy link
Contributor

Luflosi commented Sep 16, 2019

See #1968.
The latest master should support fonts with spacing=90. Try using kitty-git from the AUR until the next version is released.

@frabjous
Copy link

See #1968.
The latest master should support fonts with spacing=90. Try using kitty-git from the AUR until the next version is released.

Thanks to both! I've switched to the git version for now and all is well.

@phantomwhale
Copy link

Just chipping in I had this issue with new MacOS, and the problem ended up being the Fira fonts had been installed via Brew, but in a different account, so I didn't have them available to my new account.

brew cask reinstall font-fira-code fixed it for me. Everything above was super helpful in debugging this. Thanks all for the comprehensive discussion.

@Kabouik
Copy link

Kabouik commented May 18, 2021

I'm having a similar issue with FiraSans. It's detected by Font Manager and I can use it in other programs, I can also see it in its /usr/share/fonts sub-directory, but kitty doesn't find it. I have tried with using hyphens instead of a space between the font name and the style, as well as a space between "Fira" and "Sans", but that didn't change. As a comparison, FiraCode Light works.

fc-list -v FiraSans | grep spacing returns no match. Is that the cause?

ss-2021-05-18_095442

[Edit] Wait, turns out FiraSans is not monospaced. I'll use FiraMono instead.

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