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

Private Use Unicode characters not rendered on macOS with bold/italic set #6043

Closed
antoineco opened this issue Feb 20, 2023 · 3 comments
Closed
Labels

Comments

@antoineco
Copy link

antoineco commented Feb 20, 2023

Describe the bug

With Symbols Nerd Font Mono used as fallback font, characters in the Private Use Unicode range disappear or are rendered improperly when the italic or bold attributes are set.

For example:

  • The character U+E725 — which is used for nf-dev-git_branch — becomes invisible.
  • The character U+E0A0 — which is used for nf-pl-branch — turns into a different symbol.

I assume this is happening because the fallback font doesn't have a Bold or Italic variant installed, which might not even be true because things work fine with a Regular patched font (see additional comments).

To Reproduce

  1. Install Symbols Nerd Font Mono 2048-em, which kitty should automatically fall back to.

  2. Open (Neo)vim (defaults)

  3. Ensure the StatusLine highlight group has cterm=bold or cterm=italic.

  4. :set statusline=\ main
    :set statusline=\ main

Screenshots

default_status_hl
nf_merge
nf_branch

Below, there should be a U+E725 symbol between the two x, but not when the line is commented:
default_comment_italic

Environment details

Debug output
kitty 0.27.1 () created by Kovid Goyal
Darwin acotten-mbp13 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64
ProductName:		macOS ProductVersion:		13.1 BuildVersion:		22C65
Frozen: True
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/acotten/.config/kitty/kitty.conf

Config options different from defaults:
active_tab_font_style   (True, False)
disable_ligatures       1
font_family             Cascadia Code
font_size               15.0
initial_window_height   (32, 'cells')
initial_window_width    (140, 'cells')
remember_window_size    False
tab_bar_style           powerline
tab_powerline_style     slanted
Colors:
	active_border_color     #a7c080   
	active_tab_background   #2d353b   
	active_tab_foreground   #d3c6aa   
	background              #2d353b   
	bell_border_color       #e69875   
	color0                  #343f44   
	color1                  #e67e80   
	color10                 #a7c080   
	color11                 #dbbc7f   
	color12                 #7fbbb3   
	color13                 #d699b6   
	color14                 #83c092   
	color15                 #9da9a0   
	color2                  #a7c080   
	color3                  #dbbc7f   
	color4                  #7fbbb3   
	color5                  #d699b6   
	color6                  #83c092   
	color7                  #859289   
	color8                  #3d484d   
	color9                  #e67e80   
	cursor                  #d3c6aa   
	cursor_text_color       #343f44   
	foreground              #d3c6aa   
	inactive_border_color   #56635f   
	inactive_tab_background #3d484d   
	inactive_tab_foreground #9da9a0   
	mark1_background        #7fbbb3   
	mark1_foreground        #2d353b   
	mark2_background        #d3c6aa   
	mark2_foreground        #2d353b   
	mark3_background        #d699b6   
	mark3_foreground        #2d353b   
	selection_background    #543a48   
	selection_foreground    #9da9a0   
	tab_bar_background      #343f44   
	url_color               #7fbbb3   

Important environment variables seen by the kitty process:
	PATH                                /Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
	LANG                                en_US.UTF-8
	SHELL                               /bin/zsh
	USER                                acotten

Additional context

Can't reproduce with a patched Nerd Font, even if I only install the Regular style.

image

$ kitty +list-fonts
CaskaydiaCove Nerd Font Mono
    CaskaydiaCove Nerd Font Mono Regular

Symbols Nerd Font Mono
    Symbols Nerd Font Mono 2048-em
# kitty.conf
font_family CaskaydiaCove Nerd Font Mono
font_size   15.0
@antoineco antoineco added the bug label Feb 20, 2023
@kovidgoyal
Copy link
Owner

This will be a limitation of CoreText, which is used for fallback on
macOS. You can fix it by defining symbol_map in kitty.conf as
described in the FAQ
https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font

It might be worth working around this by detecting when CoreText is
falling back to the last resort font for a PUA and nuking bold/italic
and retrying. Something for a rainy day, or of course, patches welcome.

@antoineco
Copy link
Author

antoineco commented Feb 20, 2023

symbol_map U+E725 Symbols Nerd Font Mono solves the problem for me indeed 👍 Thanks for the hint.

@antoineco antoineco changed the title Private Use Unicode characters not rendered in Vim with bold/italic set Private Use Unicode characters not rendered on macOS with bold/italic set Feb 20, 2023
antoineco added a commit to antoineco/dotfiles that referenced this issue Feb 20, 2023
LunarVim uses the nf-dev-git_branch devicon inside the 'b' section of
its statusline. Most colorschemes use bold text in the corresponding
highlight group(s), resulting in rendering glitches on macOS while
relying on kitty's font fallback mechanism.

This affects all symbols in the Private Use Unicode range, but this
particular one seems to be the only problematic symbol in my current Vim
setup.

Ref. kovidgoyal/kitty#6043
@kovidgoyal
Copy link
Owner

master now correctly applies bold and italics to fallback fonts. My diagnosis of this issue was likely incorrect to start with, as before my latest fix kitty did not use bold/italic attributes at all when looking for fallback fonts on macOS. The problem was likely CoreText fallback using a different font than nerd font for those code points. In any case the proper fix is to use symbol_map to ensure kitty uses the font you want for these symbols, regardless of CoreText's mysterious fallback algorithms.

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

2 participants