wez / wezterm

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

Font (Iosevka) looks kinda wide and low? #689

Closed GoldsteinE closed 3 years ago

GoldsteinE commented 3 years ago

Describe the bug

This is the same file, with same font (ttf-iosevka from AUR), opened in Wezterm nightly (left) and Alacritty (right). image Alacritty's rendering looks more slender and Iosevkaish, while Wezterm's is kinda wide and low. It's also observable from tput cols: it shows 86 for Alacritty and 79 for Wezterm when windows are the exact same size. tput lines is 36 for both Wezterm and Alacritty, but there's tab line in Wezterm, so it's actually 37.

Environment (please complete the following information):

To Reproduce

Dunno. I run fully-updated Arch Linux, with wezterm-git and ttf-iosevka from AUR, and i3-gaps as my WM. I'm not sure what exactly is causing this behaviour.

Configuration

local w = require 'wezterm'

return {
    font = w.font('iosevka'),
    font_size = 16,
}

Also my Alacritty config in the case it helps:

font:
  normal:
    family: Iosevka
  size: 11  # sic! I'm not sure why Wezterm requires 16 to get roughly same size
  offset:
    x: 0
    y: 0
  glyph_offset:
    x: 0
    y: 0
  use_thin_strokes: false

Expected behavior

Iosevka is rendered tall and slender, as it should be.

wez commented 3 years ago

Can you run wezterm ls-fonts and share the output? That should show information about the font-stretch properties of the font that was selected. By default, the selected stretch is Normal, but you may wish to specify a more condensed variant. https://wezfurlong.org/wezterm/config/lua/wezterm/font.html has some more info on specifying fonts.

GoldsteinE commented 3 years ago

I tried to specify different stretch options, but it changes nothing for me. wezterm ls-fonts gives me Expanded as a default stretch? Can't understand why:

Primary font:
  wezterm.font("Iosevka", weight="Regular", stretch="Expanded", italic=false)
    (/usr/share/fonts/TTF/iosevka-extended.ttf, FontConfig)

  wezterm.font("Iosevka", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/TTF/iosevka-regular.ttf, FontConfig)

Manually specifying { stretch = "Normal" } also changes nothing.

wez commented 3 years ago

Please run: WEZTERM_LOG=wezterm_font=trace wezterm ls-fonts and share the complete output. That will include verbose diagnostics about the font-config query and results

GoldsteinE commented 3 years ago

Here it is. https://gist.github.com/GoldsteinE/f2ab1968a8c16e3bf1944f98f3ff303f

wez commented 3 years ago

It looks like font-config is returning the expanded font:

2021-04-13T15:34:58.683Z TRACE wezterm_font::locator::font_config > fc pattern before config subst: Pattern(Iosevka:slant=0:weight=80:spacing=100) 2021-04-13T15:34:58.694Z TRACE wezterm_font::locator::font_config > best match took 11.741586ms to compute and is Pattern(Iosevka,Iosevka Extended:style=Extended,Regular:slant=0:weight=80:spacing=100:file=/usr/share/fonts/TTF/iosevka-extended.ttf:index=0:charset=20-7e a0-2e9 2ec-2ed 2ef-2f3 2f7 300-35a 35c-36f 37a-37f 384-38a 38c 38e-3a1 3a3-3ce 3d1 3d5-3d6 3f2-3f4 3f7-3f9 3fd-45f 462-463 466-46d 472-479 490-49b 4a0-4a5 4aa-4b3 4b6-4bb 4c0-4c2 4c7-4c8 4cb-4cc 4cf-4f9 51a-51d e3f 1ab2 1abb 1abd 1abf-1ac0 1d00-1d10 1d14-1d1c 1d20-1d58 1d5a-1d6b 1d77-1d78 1d7b-1d7d 1d7f 1d8f-1d91 1d99 1d9b-1da9 1dab-1dbf 1dc4-1dc7 1dca 1dce 1dd4 1dd7-1deb 1ded-1df4 1dfe 1e00-1ef9 1f00-1f15 1f18-1f1d 1f20-1f45 1f48-1f4d 1f50-1f57 1f59 1f5b 1f5d 1f5f-1f7d 1f80-1fb4 1fb6-1fc4 1fc6-1fd3 1fd6-1fdb 1fdd-1fef 1ff2-1ff4 1ff6-1ffe 2000-200d 2010-2027 202f-2040 2043-2049 204b 2050 2052-2054 205d 2070-2071 2074-208e 2090-209c 20a3-20a4 20a6-20a9 20ac 20af 20b9 20bd 20bf 20d6-20d7 20e1 2100-2103 2105-2106 2109 210d-210e 2113 2115-2117 2119-211a 211d 2120-2122 2124 2126-2127 2129-212b 212e 2132 2135-2136 213b-2141 2145-2149 214b 214d-214e 2150-215e 2180 2183-2184 2189-218b 2190-21aa 21ad-21ae 21b0-21d9 21de-21e9 21f3 21f5 21f7-21fc 2200-2220 2223-223a 223c-223e 2241-226b 226d-22b9 22bb-22bd 22bf-22d3 22d5-22d7 22da-22f1 22f8 22ff 2302 2305-2306 2308-230b 2310 231c-2321 2329-232a 2336-237a 2389-238a 2395 239b-23ae 23b0-23b1 23cf 23f4-23fe 2400-2421 2423-2424 2460-2600 2605-2606 2610-2612 2630-2637 2639-263c 2640-2642 2660-2667 2669-266f 2680-2687 268a-2691 2699 269b 26a1 26aa-26ab 2713-2718 271a 2731 2733-2734 2736-273a 274c 276c-2771 2776-277f 2794 27a1 27a5-27a6 27c2 27dc 27e6-27eb 27f5-27f6 2800-28ff 2908-2909 2912-2913 2921-2926 294a-294d 2982-2984 2987-2988 29e8-29e9 29eb 29f4 2a00-2a02 2a11-2a16 2a1f 2a3e-2a40 2a53-2a54 2a7d-2a7e 2a85-2a8a 2aaf-2aba 2afd 2b00-2b0d 2b12-2b2f 2b50-2b55 2b58 2b95 2bc0-2bc8 2bca-2bcb 2be8-2beb 2c62 2c69-2c6d 2c6f-2c73 2c75-2c77 2c79 2c7b-2c7f 2e18 3251-325f 32b1-32bf a708-a716 a722-a727 a730-a731 a75a-a75b a780-a781 a78e a792-a793 a7af-a7b1 a7ba-a7bf a7f8-a7f9 ab30 ab35 ab53 ab64-ab67 e000-e010 e0a0-e0a3 e0ae-e0bf fb01-fb02 fffc-fffd 1d400-1d454 1d456-1d49b 1d538-1d539 1d53b-1d53e 1d540-1d544 1d546 1d54a-1d550 1d552-1d56b 1d5a0-1d6a5 1d6a8-1d6db 1d6dd 1d6df 1d6e1-1d715 1d717 1d719 1d71b-1d74f 1d751 1d753 1d755-1d789 1d78b 1d78d 1d78f-1d7c3 1d7c5 1d7c7 1d7c9 1d7ce-1d7ff 1f100-1f10a 1f10d 1f110-1f16d 1f170-1f189 1f18b-1f19a 1f1ad 1f780-1f7bf 1f850-1f859 1f860-1f887 1f8b0-1f8b1 1fb00-1fbca 1fbf0-1fbf9:fontformat=TrueType)

What does:

fc-match Iosevka -v output for you?

Then also:

fc-match Iosevka:width=100 -v

GoldsteinE commented 3 years ago

fc-match Iosevka -v: https://gist.github.com/GoldsteinE/f82167a35b37b59220c48fa2059cdb90 fc-match Iosevka:width=100 -v: https://gist.github.com/GoldsteinE/1cfd23752e6589c70fe776dc0f0bf6bd

wez commented 3 years ago

And hopefully the last one:

fc-match Iosevka:spacing=100:width=100 -v

GoldsteinE commented 3 years ago

It's probably is the last one, since it's Iosevka Extended. https://gist.github.com/GoldsteinE/60ab031710caef539f198c785dc6246e

wez commented 3 years ago

Hmm, well this is tricky. spacing=100 is monospace where every glyph has the same width. spacing=90 is something that fontconfig calls "dual" space, which is where every glyph has one of two possible widths.

we ask fontconfig for monospace fonts first, and fontconfig returns the Extended font. Because that matched, we don't then ask for dual spacing fonts.

Normally I'd suggest using the postscriptname to match in this situation, but for the regular font, its poscriptname is the same as the family name (https://gist.github.com/GoldsteinE/f82167a35b37b59220c48fa2059cdb90#file-gistfile1-txt-L75) so we'll never trigger the postscriptname lookup.

I think what this is telling me is that we can't really rely on fontconfig to match fonts correctly(!) and that I'll need to make some changes to get all fonts that match the family name from fontconfig and then perform the font matching in wezterm.

In the meantime, what I'd suggest is this configuration:

local w = require 'wezterm'

return {
    font_locator = "ConfigDirsOnly", -- don't use font-config, only font_dirs
    font_dirs = {"/usr/share/fonts/TTF"},
    font = w.font('iosevka'),
    font_size = 16,
}
GoldsteinE commented 3 years ago

Many thanks for your help! In my particular case (I actually use patched version of Iosevka, and switched to AUR's just for this bug report) I can afford to just delete Iosevka Extended from my system, so only normal variant is available.

GoldsteinE commented 3 years ago

Okay that's weird. I removed Iosevka GM Extended files from my computer, did fc-cache -r and set the font to Iosevka GM. wezterm uses the exact same Iosevka GM.ttf that Alacritty uses, and the font is still different. WEZTERM_LOG=wezterm_font=trace wezterm ls-fonts: https://gist.github.com/GoldsteinE/6896ef7fe67b405e5637e2d1a6a06f63 fc-match 'Iosevka GM:spacing=100:width=100' https://gist.github.com/GoldsteinE/902291adb68ce7f7833dcdffb43e8004

I suppose Iosevka GM.ttf somehow contains both regular and extended version, and I want to use regular, but some Wezterm/fontconfig machinery chooses extended.

GoldsteinE commented 3 years ago

Setting explicit font location helped, except font is now... bold? Fonts are hard.

image

Setting then font = w.font('Iosevka GM', { bold = false }) gave me wide font once again.

wez commented 3 years ago

I've pushed some changes that should hopefully reconcile the matching stuff. Would you mind updating wezterm-git and trying it out? If it still doesn't work out, please share the WEZTERM_LOG=wezterm_font=trace,info wezterm ls-fonts output so we can see what's happening!

no-response[bot] commented 3 years ago

This issue has been automatically closed because there has been no response to the request for more information from the original author. With only the information that is currently in the issue, there isn't enough information to take further action. Please reach out if you have or find the answers we need so that we can investigate further.

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.