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

Cannot resolve font with fontconfig 2.13.96 #4649

Closed
sQVe opened this issue Feb 7, 2022 · 11 comments
Closed

Cannot resolve font with fontconfig 2.13.96 #4649

sQVe opened this issue Feb 7, 2022 · 11 comments
Labels

Comments

@sQVe
Copy link

sQVe commented Feb 7, 2022

Describe the bug
I set my font via fontconfig and with the following section:

<alias>
  <family>term</family>
  <prefer>
    <family>Iosevka Nerd Font</family>
    <family>Symbols Nerd Font</family>
    <family>Noto Color Emoji</family>
    <family>Symbola</family>
  </prefer>
</alias>
# Font specific.
font_family term
bold_font auto
italic_font auto
bold_italic_font auto
disable_ligatures always
font_size 10.0

I just updated fontconfig from 2.13.94 to 2.13.96 and my alias isn't working anymore. Downgrading fontconfig solves it.

To Reproduce
Steps to reproduce the behavior:

  1. Update to latest fontconfig (2.13.96).
  2. Add an font alias to fonts.conf.
  3. Use the font alias in `kitty.
  4. Font isn't loaded properly.

Environment details

kitty 0.24.2 created by Kovid Goyal
Linux calcifer 5.16.5-arch1-1 #1 SMP PREEMPT Tue, 01 Feb 2022 21:42:50 +0000 x86_64
CALCIFER

Running under: X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /usr/bin/zsh
Loaded config files:
  /home/sqve/.config/kitty/kitty.conf

Config options different from defaults:
cursor_blink_interval 0.0
disable_ligatures     2
enable_audio_bell     False
enabled_layouts       ['grid', 'horizontal', 'vertical']
font_family           term
font_size             10.0
open_url_with         ['mimeo']
remember_window_size  False
scrollback_pager      ['/home/sqve/scripts/kitty/neovim-scrollback.sh']
shell_integration     frozenset({'no-cursor'})
tab_bar_style         separator
tab_separator          │ 
window_padding_width  FloatEdges(left=2.0, top=2.0, right=2.0, bottom=2.0)
Added shortcuts:
  ctrl+shift+p → previous_window
  ctrl+alt+l → kitten hints --type line --program -
  ctrl+alt+p → kitten hints --type path --program -
  ctrl+alt+u → kitten hints --type path
  ctrl+alt+w → kitten hints --type word --program -
Removed shortcuts:
  ctrl+shift+p > f → kitten hints --type path --program -
  ctrl+shift+p > h → kitten hints --type hash --program -
  ctrl+shift+p > l → kitten hints --type line --program -
  ctrl+shift+p > n → kitten hints --type linenum
  ctrl+shift+p > w → kitten hints --type word --program -
  ctrl+shift+p > y → kitten hints --type hyperlink
  ctrl+shift+p > shift+f → kitten hints --type path
Changed shortcuts:
  ctrl+shift+n → next_window
Colors:
  background            #282828   
  color0                #665c54   
  color1                #ea6962   
  color10               #a9b665   
  color11               #d8a657   
  color12               #7daea3   
  color13               #d3869b   
  color14               #89b482   
  color15               #d4be98   
  color2                #a9b665   
  color3                #e78a4e   
  color4                #7daea3   
  color5                #d3869b   
  color6                #89b482   
  color7                #d4be98   
  color8                #928374   
  color9                #ea6962   
  cursor                #ebdbb2   
  cursor_text_color     #282828   
  foreground            #fbf1c7   
  selection_background  #44475a   
  selection_foreground  #ebdbb2   

Environment variable names seen by the kitty process:
  ANDROID_AVD_HOME
  ANDROID_EMULATOR_HOME
  ANDROID_SDK_HOME
  AWS_CONFIG_FILE
  BIN
  BIN_HOME
  BOOKS
  BROWSER
  CODE
  CUDA_CACHE_PATH
  DBUS_SESSION_BUS_ADDRESS
  DISPLAY
  DOCKER_CONFIG
  DOTFILES
  DOWNLOAD
  EDITOR
  ESLINT_D_LOCAL_ESLINT_ONLY
  EXA_COLORS
  FZF_ALT_C_COMMAND
  FZF_ALT_C_OPTS
  FZF_CTRL_T_COMMAND
  FZF_CTRL_T_OPTS
  FZF_DEFAULT_COMMAND
  FZF_DEFAULT_OPTS
  GIT_SSH_COMMAND
  GONOSUMDB
  GOPATH
  GOPATH_BIN
  GOPROXY
  GPG_TTY
  GREP_COLORS
  GTK2_RC_FILES
  GTK3_MODULES
  GTK_MODULES
  HISTFILE
  HOME
  HTTPIE_CONFIG_DIR
  I3SOCK
  INVOCATION_ID
  KEYTIMEOUT
  KUBECONFIG
  LANG
  LC_MESSAGES
  LESS
  LESSHISTFILE
  LESSOPEN
  LOGNAME
  LS_COLORS
  MAIL
  MOTD_SHOWN
  NODE_REPL_HISTORY
  NOTES
  NPM_CONFIG_CACHE
  NPM_CONFIG_USERCONFIG
  NVM_DIR
  OLDPWD
  PAGER
  PASSWORDS
  PASSWORD_STORE_DIR
  PASSWORD_STORE_GENERATED_LENGTH
  PASSWORD_STORE_GPG_OPTS
  PATH
  PERSISTENT_CACHE
  PICTURES
  PRETTIERD_LOCAL_PRETTIER_ONLY
  PROMPT_LEAN_VIMODE
  PROMPT_LEAN_VIMODE_FORMAT
  PWD
  RCRC
  RIPGREP_CONFIG_PATH
  SCRIPTS
  SHELL
  SHLVL
  SSB_HOME
  SSH_AUTH_SOCK
  SUDO_ASKPASS
  SYSTEMD_EXEC_PID
  TERM
  TERMINAL
  TRASH
  USER
  VISUAL
  WEECHAT_HOME
  WINDOWPATH
  WINIT_X11_SCALE_FACTOR
  WORK
  XAUTHORITY
  XDG_CACHE_HOME
  XDG_CONFIG_HOME
  XDG_DATA_HOME
  XDG_RUNTIME_DIR
  XDG_SEAT
  XDG_SESSION_CLASS
  XDG_SESSION_ID
  XDG_SESSION_TYPE
  XDG_STATE_HOME
  XDG_VTNR
  YARN_CACHE_FOLDER
  YVM_DIR
  ZDOTDIR
  ZIM_HOME
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
  ZSH_AUTOSUGGEST_USE_ASYNC
  _
  _ZL_DATA
  _ZL_FZF_FLAG
  _ZL_MATCH_MODE
@sQVe sQVe added the bug label Feb 7, 2022
@kovidgoyal
Copy link
Owner

Then report it to the fontconfig project.

@kovidgoyal
Copy link
Owner

And just for the record, you dont need to do all this dancing in
fontconfig. Simply set unpatched Iosevka see the note here: https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font

@sQVe
Copy link
Author

sQVe commented Feb 7, 2022

Sure - I'll do that.

What's confusing is that my fontconfig setup works fine for other applications, like i3wm, which is why I reported it here first as kitty is the only application I've seen so far that has problems resolving the fonts.

@kovidgoyal
Copy link
Owner

It isn't not resolving the font, fontconfig has probably reclassified it
as non-monospace, one of the hazards of using patched fonts. Just use
unpatched ones.

@sQVe
Copy link
Author

sQVe commented Feb 7, 2022

Great tip @kovidgoyal.

I'm trying to find the standalone NERD font but the closes I'm finding on my system (Arch) is ttf-nerd-fonts-symbols. 🤔

@page-down
Copy link
Contributor

I'm trying to find the standalone NERD font ...

I get it from the following location.

https://github.com/ryanoasis/nerd-fonts/tree/2.2.0-RC/src/glyphs

Symbols-1000-em Nerd Font Complete.ttf

I had compared the file hash from that package before and it is the same.

@sQVe
Copy link
Author

sQVe commented Feb 7, 2022

@page-down Thank you! ❤️

I just tried running:

<alias>
  <family>term</family>
  <prefer>
    <family>Iosevka</family>
  </prefer>
</alias>

and it's still unable to resolve the font 🤔

@page-down
Copy link
Contributor

page-down commented Feb 7, 2022

I installed and tried it specifically. Can not reproduce this.

https://github.com/be5invis/Iosevka/releases/download/v11.3.0/ttc-sgr-iosevka-11.3.0.zip

# Arch Linux
# fontconfig 2:2.13.96-1
# kitty 0.24.2 from github releases, and kitty compiled from src

# kitty -o 'font_family term' --debug-font-fallback
Preloaded font faces:
normal face: ~/.local/share/fonts/sgr-iosevka-regular.ttc:0
bold face: ~/.local/share/fonts/sgr-iosevka-bold.ttc:0
italic face: ~/.local/share/fonts/sgr-iosevka-regular.ttc:3
bi face: ~/.local/share/fonts/sgr-iosevka-bold.ttc:3

It is worth noting that I did not install kitty from archlinux.

EDIT:
I tried what you mentioned below, and it does get abnormal if you make aliases to monospace. (archlinux fontconfig 2.13.96-1)
When I downgraded to fontconfig 2.13.94 it was back to normal.

@sQVe
Copy link
Author

sQVe commented Feb 7, 2022

@page-down Cheers for helping me debug this! ❤️ I've now narrowed this down to:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <!-- Set preferred serif, sans serif, and monospace fonts. -->
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Cousine</family>
      <family>Noto Color Emoji</family>
    </prefer>
  </alias>
  <alias>
    <family>term</family>
    <prefer>
      <family>Iosevka</family>
      <family>Symbols Nerd Font</family>
      <family>Noto Color Emoji</family>
      <family>Symbola</family>
    </prefer>
  </alias>
</fontconfig>

Strangely enough it seems like kitty prefers the monospace alias before my term alias that I specifically set. Everything resolves nicely if I remove the monospace alias.


Running fc-match "term" give me:

iosevka-regular.ttc: "Iosevka" "Regular"

but kitty -o 'font_family term' --debug-font-fallback gives me:

[038 14:34:54.265336] Preloaded font faces:
[038 14:34:54.265374] normal face: /usr/share/fonts/croscore/Cousine-Regular.ttf:0
[038 14:34:54.265387] bold face: /usr/share/fonts/croscore/Cousine-Bold.ttf:0
[038 14:34:54.265402] italic face: /usr/share/fonts/croscore/Cousine-Italic.ttf:0
[038 14:34:54.265413] bi face: /usr/share/fonts/croscore/Cousine-BoldItalic.ttf:0

@sQVe
Copy link
Author

sQVe commented Feb 7, 2022

I "sort of" solved this by using the monospace alias instead of the term alias.

sQVe/dotfiles@d145168#diff-4fb4286f5f5e882fcae1801191828518c19485e7ce77727b05f47838fa3db65c

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 7, 2022

That happens because Iosevka is dual spaced not monospaced so fc-match returns your actual monospaced font and because you are selecting it by an alias not an actual font name, there is no way for kitty to check if fc-match has returned what you wanted. Check it yourself with:

fc-match term:spacing=mono

@kovidgoyal kovidgoyal reopened this Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants