wez / wezterm

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

Some specific ligatures are not used (strings: </ </> /> /* */ \/ /\ ; font: Iosevka ; comparison: konsole) #4711

Closed AndydeCleyre closed 10 months ago

AndydeCleyre commented 10 months ago

What Operating System(s) are you seeing this problem on?

Linux X11

Which Wayland compositor or X11 Window manager(s) are you using?

Plasma/KWin (X11)

WezTerm version

20231203-124028-e3cd2e93

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Just a handful of Iosevka's ligatures/ligations don't seem to render as such, using a build of Iosevka which has dlig set as the default. The specific build I'm testing is here: Iosevka Term Custom.

Here's a screenshot of the same tmux session rendered with Konsole (top) and Wezterm (bottom). The blue items are not expected to be rendered as ligatures, and are fine. The majority of ligatures are also fine. The red items are expected to be rendered as ligatures and do so in Konsole (and Firefox and Sublime Text), but not Wezterm.

ligatures_konsole_wezterm

To Reproduce

Zsh:

print -rlP -- '-<< --< -<- <-- <--- <<- <- -> ->> --> ---> ->- >- >>=' '=<< =< =<= <== <=== <<= <= => =>> ==> ===> =>= >= >>=' '<-> <--> <---> <----> <=> <==> <===> <====> :: ::: __' '<~~ %F{red}</ </> />%f ~~> == != %F{blue}/= ~=%f <> === !== !=== %F{blue}=/= =!=%f' '<: := *= *+ <* <*> *> <| <|> |> <. <.> .> +* =* =: :>' '(* *) %F{red}/* */%f [| |] {| |} ++ +++ %F{red}\/ /\%f \- -| <!-- <!---'

Configuration

local wezterm = require 'wezterm'

local scheme = wezterm.get_builtin_color_schemes()["Red Planet"]

scheme.background = "#1f1f28"
scheme.ansi[8] = "#dea050"
scheme.brights[8] = "#de9231"

return {
  color_schemes = { ["ConfiguredColors"] = scheme },
  color_scheme = "ConfiguredColors",

  font_size = 24,
  font = wezterm.font_with_fallback({
    "Iosevka Term Custom",
    "0xProto",
    "Sudo",
    "Fantasque Sans Mono",
    "Nimbus Mono PS",
    "Symbols Nerd Font",
    "NanumGothicCoding",
    "OpenMoji",
    "JoyPixels",
    "Untitled1"
  }),
  harfbuzz_features = { 'thnd', 'frac', 'txtr' },

  disable_default_key_bindings = true,
  keys = {
    { key = '=', mods = 'CTRL',       action = wezterm.action.IncreaseFontSize },
    { key = '-', mods = 'CTRL',       action = wezterm.action.DecreaseFontSize },
    { key = '0', mods = 'CTRL',       action = wezterm.action.ResetFontSize },
    { key = 'v', mods = 'SHIFT|CTRL', action = wezterm.action.PasteFrom 'Clipboard' },
  },

  animation_fps = 30,
  default_cursor_style = "SteadyBar",
  canonicalize_pasted_newlines = "LineFeed",
  enable_tab_bar = false,

  check_for_updates = false,
}

Expected Behavior

I would expect the following to be rendered in ligature form:

Logs

No response

Anything else?

No response

wez commented 10 months ago

You can run wezterm ls-fonts --text "something" to have wezterm explain the shaping plan for a snippet of text. I would suggest pasting in the sequence that isn't shaping as you expect there and sharing what you see.

AndydeCleyre commented 10 months ago
$ wezterm ls-fonts --text '</'  # expect lig, but get no lig
LeftToRight
 0 <    \u{3c}       x_adv=16 cells=1  glyph=31   wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig
 1 /    \u{2f}       x_adv=16 cells=1  glyph=12238 wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig

$ wezterm ls-fonts --text '<>'  # expect lig, indeed get lig
LeftToRight
 0 <    \u{3c}       x_adv=16 cells=1  glyph=13418 wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig
 1 >    \u{3e}       x_adv=16 cells=1  glyph=13419 wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig

$ wezterm ls-fonts --text '/='  # expect no lig, indeed get no lig
LeftToRight
 0 /    \u{2f}       x_adv=16 cells=1  glyph=12238 wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig
 1 =    \u{3d}       x_adv=16 cells=1  glyph=32   wezterm.font("Iosevka Term Custom", {weight="Regular", stretch="Normal", style="Normal"})
                                      /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf, FontConfig
wez commented 10 months ago

The harfbuzz_features setting in your config may be disabling some of the default ligature related options.

The default value is harfbuzz_features = { 'kern', 'liga', 'clig'}

So I'd suggest setting:

harfbuzz_features = { 'kern', 'liga', 'clig', 'thnd', 'frac', 'txtr' }

otherwise: wezterm is just using what harfbuzz decides. You may also wish to try using its utilities directly to compare:

$ hb-shape /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf -u 3c,2f

This will render an image directly to the terminal:

$ hb-view /home/andy/.local/share/fonts/IosevkaTermCustom-Regular.ttf -u 3c,2f
AndydeCleyre commented 10 months ago

Thanks! The hb-view command does use the ligature.

I didn't realize I was removing harfbuzz options by adding them there, whoops!

Using

harfbuzz_features = { 'kern', 'liga', 'clig', 'thnd', 'frac', 'txtr' }

also does not result in those particular ligatures being used, but removing the line altogether does end up rendering them as ligatures.

Ah, it seems it's frac is incompatible with those slash-y ligatures. I don't know if that's a general thing, or with this font in particular or what.

wez commented 10 months ago

Glad you figured this out! I'm going to close this because it is not a wezterm issue.

AndydeCleyre commented 10 months ago

Thanks again for the help. I do think the current text at your font shaping docs is misleading, as it for example suggests:

config.harfbuzz_features = { 'zero' }

without any indication that this is destructive of some default and unrelated values.

github-actions[bot] commented 9 months 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.