wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.55k stars 785 forks source link

CLI command to list available/current fonts with the current config #347

Closed bew closed 3 years ago

bew commented 3 years ago

Is your feature request related to a problem? Please describe. When I'm configuring and tweaking my font settings, trying new fonts, it's difficult to know which font is available with the current config, or which font is really selected.

Describe the solution you'd like A cli command like wezterm list-fonts that would output something like:

Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
Iosevka Term Bold Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbold.ttf)
Iosevka Term Bold Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbolditalic.ttf)
Iosevka Term Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extended.ttf)
Iosevka Term Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendeditalic.ttf)
JetBrains Mono Bold (builtin)
JetBrains Mono Bold Italic (builtin)
JetBrains Mono Extra Bold (builtin)
JetBrains Mono Extra Bold Italic (builtin)
JetBrains Mono Extra Light (builtin)
JetBrains Mono Extra Light Italic (builtin)
JetBrains Mono Italic (builtin)
JetBrains Mono Light (builtin)
JetBrains Mono Light Italic (builtin)
JetBrains Mono Medium (builtin)
JetBrains Mono Medium Italic (builtin)
JetBrains Mono Regular (builtin) (default)        (<----- this one is marked as the default font)
JetBrains Mono Semi Light (builtin)
JetBrains Mono Semi Light Italic (builtin)
Last Resort High-Efficiency (builtin)
Noto Color Emoji (builtin)

Or more structured:

Available fonts in the system (ordered alphabetically):
  Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
  Iosevka Term Bold Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbold.ttf)
  Iosevka Term Bold Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbolditalic.ttf)
  Iosevka Term Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extended.ttf)
  Iosevka Term Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendeditalic.ttf)

Builtin fonts (ordered by priority):       (<------ I don't know the detail, but I assume there are some priorities?)
  JetBrains Mono Bold
  JetBrains Mono Bold Italic
  JetBrains Mono Extra Bold
  JetBrains Mono Extra Bold Italic
  JetBrains Mono Extra Light
  JetBrains Mono Extra Light Italic
  JetBrains Mono Italic
  JetBrains Mono Light
  JetBrains Mono Light Italic
  JetBrains Mono Medium
  JetBrains Mono Medium Italic
  JetBrains Mono Regular
  JetBrains Mono Semi Light
  JetBrains Mono Semi Light Italic
  Noto Color Emoji
  Last Resort High-Efficiency

Additionally (if it makes sense?) there could be a flag to show the selected fonts with the current config only, like:

Fonts selected for this configuration:

Normal text:
  Iosevka Term Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extended.ttf)
  Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
  (+ builtin fallbacks)

Bold text:
  Iosevka Term Bold Extended (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbold.ttf)
  Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
  (+ builtin fallbacks)

Italic text:
  Iosevka Term Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendeditalic.ttf)
  Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
  (+ builtin fallbacks)

Italic text:
  Iosevka Term Bold Extended Italic (from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extendedbolditalic.ttf)
  Font Awesome 5 Free Solid (from /home/lesell_b/.config/wezterm/fonts/Font Awesome 5 Free-Solid-900.otf)
  (+ builtin fallbacks)

Describe alternatives you've considered A workaround to list the available fonts is to enable debug logs and read the warnings, but the output is not "clean", there are some Using font ... lines right in the middle, I'm never sure if it's from a different thread or if it shows a separation, .. And in the logs, the font names are repeated multiple times (probably due to multiple places where a font can't be found).

For example:

 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Font Awesome 5 Free Solid
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Iosevka Nerd Font Complete Mono
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Iosevka Term Bold Extended
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Iosevka Term Bold Extended Italic
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Iosevka Term Extended
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Iosevka Term Extended Italic
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > available font: Noto Color Emoji
 2020-11-23T21:40:49.001Z WARN  wezterm_font::parser > Using Iosevka Term Extended from /home/lesell_b/.config/wezterm/fonts/iosevka-term-extended.ttf for FontAttributes { family: "Iosevka Term Extended", bold: false, italic: false, is_fallback: false }
 2020-11-23T21:40:49.122Z WARN  wezterm_font::parser > available font: JetBrains Mono Bold
 2020-11-23T21:40:49.122Z WARN  wezterm_font::parser > available font: JetBrains Mono Bold Italic
 2020-11-23T21:40:49.122Z WARN  wezterm_font::parser > available font: JetBrains Mono Extra Bold
 2020-11-23T21:40:49.122Z WARN  wezterm_font::parser > available font: JetBrains Mono Extra Bold Italic
[...]
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > available font: JetBrains Mono Semi Light
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > available font: JetBrains Mono Semi Light Italic
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > available font: Last Resort High-Efficiency
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > available font: Noto Color Emoji
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > Using JetBrains Mono Regular from memory for FontAttributes { family: "JetBrains Mono", bold: false, italic: false, is_fallback: true }
 2020-11-23T21:40:49.128Z WARN  wezterm_font::parser > Using Noto Color Emoji from memory for FontAttributes { family: "Noto Color Emoji", bold: false, italic: false, is_fallback: true }
 2020-11-23T21:40:49.132Z WARN  wezterm_font::parser > Using Last Resort High-Efficiency from memory for FontAttributes { family: "Last Resort High-Efficiency", bold: false, italic: false, is_fallback: true }
felixjung commented 3 years ago

I would really like this. Since a few builds ago wezterm has started to reject my configured fonts. Having a way to list available fonts would help a lot!

Unable to load a font matching FontAttributes { family: "Operator Mono SSm Lig
Medium", bold: false, italic: false, is_fallback: false }. Fallback(s)
                     are being used instead, and the terminal may not
                     render as intended

Unable to load a font matching FontAttributes { family: "Operator Mono SSm Lig
Medium", bold: false, italic: false, is_fallback: false }. Fallback(s)
                     are being used instead, and the terminal may not
                     render as intended

Unable to load a font matching FontAttributes { family: "Operator Mono SSm Lig
Medium", bold: false, italic: false, is_fallback: false }. Fallback(s)
                     are being used instead, and the terminal may not
                     render as intended

Unable to load a font matching FontAttributes { family: "Operator Mono SSm Lig
Medium", bold: false, italic: false, is_fallback: false }. Fallback(s)
                     are being used instead, and the terminal may not
                     render as intended

Unable to load a font matching FontAttributes { family: "Operator Mono SSm Lig
Medium", bold: true, italic: false, is_fallback: false }. Fallback(s)
                     are being used instead, and the terminal may not
                     render as intended
wez commented 3 years ago

@felixjung https://github.com/wez/wezterm/commit/65ac2269dd18b561be6fc7827738ce86dff7b2b6 and https://github.com/wez/wezterm/issues/340 seem relevant to that specific problem!

felixjung commented 3 years ago

Ha, yes thanks. I was just browsing the issues to see if something new had popped up. 😅

wez commented 3 years ago

Overall, yes, I think something like this would help. There are some tricky cases where it may not be possible to do exactly what you want: the font locators on a system don't necessarily know what the full set of fonts are, but can try to find one by name. I do think that it is reasonable to improve diagnostics around what was found and resolved, and for the font dirs that wezterm searches, that can include the names of those fonts.

bew commented 3 years ago

Hello @wez, while ls-fonts is great, it does not help that much when trying to know which font are available.

I understand that you can't know the full list, but even a partial list can be helpful I think. (with a note at the end mentioning it's not the full list)

In the case where the font locator is configured with config dirs only, I think it's safe to say you can find all the fonts, no?

Or is it really not something you want to do?

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.