liamg / darktile

:waning_crescent_moon: Darktile is a GPU rendered terminal emulator designed for tiling window managers.
MIT License
3.03k stars 113 forks source link

Support for multiple fonts and fallbacks #307

Open pinpox opened 3 years ago

pinpox commented 3 years ago

It would be nice to be able to specify different fonts for normal, italic, bold and bold-italic aswell as fallback fonts.

In my current terminal e.g. I use a more "curly" font for italics: image

Additionally, it would be great to be able to specify fallbacks. I use a non-patched font as default and have specified fallbacks for powerline symbols and for emojis

image

A configuration format like this or similar could work

font:
  ligatures: true  # Enable font ligatures e.g. render '≡' instead of '==='
  normal:
    - family: "my normal font"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
    - family: "my normal fallback 1"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
    - family: "my normal fallback 2"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
  italic:
    - family: "my italic font"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
    - family: "my italic fallback 1"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
    - family: "my italic fallback 2"       # Font family. Find possible values for this by running 'darktile list-fonts'
      size: 16         # Font size
      dpi: 72          # DPI
  bold:
    # ...
  bold-italic:
    # ...
loveencounterflow commented 2 years ago

I would be thrilled if this would be possible. FWIW I find the most reasonable way to implement multiple fonts is to use CSS Unicode Character Ranges so users can map specific code points to specific fonts. This feature is what made me use Kitty terminal.

pinpox commented 2 years ago

I don't know exactly how it's implemented, but wezterm allows for multiple fonts with a configuration like this:

    font = wezterm.font_with_fallback( {
        {family="Recursive Mono Linear Static", weight="Medium"},
        "Inconsolata Nerd Font Mono",
        "Noto Color Emoji",
    }),

You don't need to define specific ranges, it just takes the first font that happens to include the character. Just adding this as a thought, character ranges would probably more precise, but require a more complicated configuration.