githubnext / monaspace

An innovative superfamily of fonts for code
https://monaspace.githubnext.com
SIL Open Font License 1.1
13.12k stars 219 forks source link

Can't enable `ss09` ligature for `=>` without enabling `<=` ligature? #219

Open ian-h-chamberlain opened 1 month ago

ian-h-chamberlain commented 1 month ago

Hi, I was testing the changes in version 1.101 (thanks for such a quick release!), particularly as related to #206, and I noticed there doesn't seem to be any way to use <= and >= without ligatures, while still enabling an arrow ligature for =>. I thought maybe i could use cv60 (or 'cv60' off?) to set this, but it seems to only have an effect with ss02 turned on (which isn't what I was looking for).

Maybe relates to #217 as well?

Here are some screenshots of combinations I tried — none of them result in the <=, >= combo I was hoping for:

Screenshot 2024-05-12 at 11 53 20 Screenshot 2024-05-12 at 11 53 44 Screenshot 2024-05-12 at 11 53 57 Screenshot 2024-05-12 at 11 54 07 Screenshot 2024-05-12 at 12 05 12

Is it expected that cv60 would work with ss09 as well, not just ss02? Or is there some other way to configure what I'm trying to accomplish here? Thank you!

heathercran commented 1 month ago

Hi @ian-h-chamberlain! Can you clarify which appearance you want to see for each of those pairs? Which ligatures exactly do you want to have enabled?

ian-h-chamberlain commented 1 month ago

Hi, sorry, I guess maybe it got lost in my description. What I would like (and I think was possible in 1.000, but not in 1.100 due to #206):

The issue seems to be that ss09 always enables the image ligature, with no ability to disable it while keeping image enabled. It's possible to replace it with , but not restore it to the original <= pair.


As a side note: https://monaspace.githubnext.com/#code-ligatures doesn't seem to work for ss09, the left and right sides of the comparison look the same in my browser, unlike the actual font when using in e.g. VSCode. It also doesn't seem to include an example for <= although ss09 does enable a ligature for that pair.

heathercran commented 1 month ago

Ok, that's what I thought, I just wanted to make sure I was understanding you correctly! I will include some more variants within cv60 in the next update, so that you'll be able to specify which version of the pair you want to see, regardless of which stylistic sets are enabled.

In the meantime, if you don't want to wait, you can use an open source font editor like FontForge to remove the <= pair from ss09, which would achieve the same result you're looking for.

I'll also make sure @idan knows about the ligatures on the website. Thanks for bringing that to our attention!

ian-h-chamberlain commented 1 month ago

Thanks for the tip! I wasn't able to get FontForge working without breaking the variable fonts (it seems to have limited support), but I managed to do it more correctly with https://github.com/fonttools/fonttools.

Posting my little script here in case anyone else finds it useful... I think this could probably be used to selectively disable any ligature as long as you know its name, so it might be a workaround for anyone else whose preferences aren't met by enabling/disabling ssXX font features:

import sys

from fontTools import ttLib

_UNWANTED_LIGATURE = "less_equal.alt"

def main():
    for font_name in sys.argv[1:]:
        print(f"Removing '{_UNWANTED_LIGATURE}' from {font_name}... ", end="")

        with ttLib.TTFont(font_name) as font:
            # Open the font file and remove the `<=` ligature (less_equal.alt)
            # while keeping >>=, => etc. in place

            for lookup in font["GSUB"].table.LookupList.Lookup:
                for subst in lookup.SubTable:
                    if not hasattr(subst, "ligatures"):
                        continue

                    if "less" not in subst.ligatures:
                        continue

                    subst.ligatures["less"] = [
                        lig
                        for lig in subst.ligatures["less"]
                        if lig.LigGlyph != _UNWANTED_LIGATURE
                    ]

            font.save(font_name)

        print("Done")

if __name__ == "__main__":
    main()