Custom font ligatures

1.9k views Asked by At

I'm using Visual Studio Code and I see all these cool font ligatures for double and triple equals, arrows, etc. and I can't help but wonder if there is any way to add new custom ones to a font or VS Code. I tried doing some web searches but I can't seem to find anything.

For example, when I'm in python, I want the lambda keyword to be displayed as the real lambda symbol λ. Would that be possible?

1

There are 1 answers

1
kennethormandy On

Those features are designed and built into the font file itself, rather than having anything to do with any one specific code editor.

If the font you’re considering adding them to is available under an open license or one that otherwise allows modifications to the software, it would be possible to add them.

A popular example of this is Fira Code, which is a modified version of the OFL-licensed Fira Mono, but with the ligature glyphs drawn specifically for the project.

There is a script for using those glyphs automatically in other fonts and generating the feature code, for fonts where the license allows modifications: https://github.com/ToxicFrog/Ligaturizer

The README describes how you can enable or disable new ligatures. Yours should be possible, because the “λ” lambda glyph probably already exists within Fira Code—otherwise you’d have to draw a new glyph as well.

The config you should need to add to ligatures.py is:

{
    # When the text has l+a+m+b+d+a…
    'chars': ['l', 'a', 'm', 'b', 'd', 'a'],

    # Use the existing `lambda` glyph from Fira Code, rather than one of the
    # custom drawn coding ligature glyphs
    'firacode_ligature_name': 'lambda',
},