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

Kitty renders some well-formed font ligatures at incorrect size #3313

Closed
ronjouch opened this issue Feb 13, 2021 · 3 comments
Closed

Kitty renders some well-formed font ligatures at incorrect size #3313

ronjouch opened this issue Feb 13, 2021 · 3 comments
Labels

Comments

@ronjouch
Copy link
Contributor

This bug is extracted from discussion in Kitty bug #2599: Ligatures - Spacing issue with MonoLisa font (I'm not sure these are two different bugs, the other bug is closed, and Kovid confirmed my bug).

Describe the bug

Kitty renders incorrectly (at an incorrect smaller size) the ligatures of Cascadia Code's recently-released version 2102.03. Before this precise font version (until version 2009.22, included), Kitty used to render its ligatures perfectly.

Chatting in a comment of Cascadia Code issue #409, here is what the font maintainer @aaronbell has to say about changes in this release he thinks might cause this behavior:

Previously, the ligatures in Cascadia were "backwards looking", which is to say that in a three glyph run, such as >>>, the final > would contain the ligature with a negative left side bearing, and normal right side bearing.

However, [starting with version 2102.03] I changed it to be "forwards looking" which means that the first > contains the ligature as that allows me to be more efficient with my code and simplifies things quite a bit. But it appears that Kitty can't deal with that.

To Reproduce
Steps to reproduce the behavior:

  1. Install Cascadia Code 2102.03 (I used the static TTF version / regular+bold. I didn't try the TTFbundle or OTF versions)
  2. kitty --config NONE -o 'font_family=Cascadia Code'
  3. Type text with ligatures (e.g. echo 'https://google.com' && echo 'a !== b' && echo '--version' && echo 'foo && bar', which has ligatures in //, &&, !==, --)
  4. Confirm with hb-shape that the ligatures don't consume more space than they should:
~ hb-shape --version
hb-shape (HarfBuzz) 2.6.4
Available shapers: graphite2,ot,fallback

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf 'hello'
[h=0+1200<168,1500,864,-1500>|e=1+1200<136,1080,928,-1100>|l=2+1200<98,1500,976,-1520>|l=3+1200<98,1500,976,-1520>|o=4+1200<136,1080,928,-1100>]

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '!=='
[exclam_equal_equal.liga=0+1200<180,1520,3240,-1620>|LIG=1+1200<0,0,0,0>|LIG=2+1200<0,0,0,0>]

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '&&'
[ampersand_ampersand.liga=0+1200<186,1440,2008,-1460>|LIG=1+1200<0,0,0,0>]

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '//'
[slash_slash.liga=0+1200<294,1610,1898,-1800>|LIG=1+1200<0,0,0,0>]

→ All the glyphs fit within the appropriate bounds:

  • The base letter width is 1200.
  • !== has a width of 3240, which is within the three cell width of 3600 (even including the LSB of 180).
  • && has a width of 2008, which is within the two cell width of 2400 (even including the LSB of 186).
  • // has a width of 1898, which is within the two cell width of 2400 (even including the LSB of 294).

Expected behavior
Kitty renders the ligatures at correct size.

Actual behavior & Screenshots
Kitty renders ligatures at an incorrect smaller font size (half, maybe?):
screenshot_kitty_2021-02-12-12:52:55

Environment details
OS: Ubuntu Linux 20.10, fully up-to-date

Output of kitty --debug-config:

kitty 0.19.3 (de0f225c45) created by Kovid Goyal
Linux rxps 5.10.15-051015-generic #202102100936 SMP Wed Feb 10 09:44:03 UTC 2021 x86_64
Ubuntu 20.10 \n \l
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.10
DISTRIB_CODENAME=groovy
DISTRIB_DESCRIPTION="Ubuntu 20.10"
Loaded config files: /home/ronanj/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:

Additional context
Problem reproduced with kitty --config NONE -o 'font_family=Cascadia Code'.

@ronjouch
Copy link
Contributor Author

Fix confirmed. Thanks Kovid!

@aaronbell
Copy link

Thank you!

@kovidgoyal
Copy link
Owner

Note that it works by checking how the font wants to render the ligature for === if it does it with trailing spacer glyphs, instead of leading ones then all ligatures are assumed to be with trailing spacer glyphs rather than leading ones. So please keep your ligatures consistent.

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

3 participants