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

ronjouch opened this issue Feb 13, 2021 · 3 comments

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

ronjouch opened this issue Feb 13, 2021 · 3 comments


Copy link

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 '' && 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'

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '!=='

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '&&'

~ hb-shape --show-extents --cluster-level=1 --shapers=ot ~/CascadiaCode-2102.03/ttf/static/CascadiaCode-Regular.ttf '//'

→ 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?):

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
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'.

Copy link
Contributor Author

Fix confirmed. Thanks Kovid!

Copy link

Thank you!

Copy link

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
None yet

No branches or pull requests

3 participants