Coding ligatures in monospaced font

Hello there,
I’m currently working on extending on of my monospaced fonts with some common code ligatures.
Fonts like Fira Code are a good reference for this, although there’s one thing I don’t quite understand;
Longer ligatures (like plus_plus_plus) still get a total width of 600 and are aligned to the right in Fira Code, giving it a very negative left side-bearing.

Why is that? If there’s no space (or 2) at the left, it would clash into a neighboring glyph all the time?
Anyone who can explain this? Am I missing a feature here?

In Monospaced fonts, all glyphs have to be the same width. You can add some GPOS rules to change the spacing later.

Is that a technical requirement?

I was told that even none spacing marks should have the same width then all other glyphs. And to use GPOS to make them zero width ;(

Aha I see, thanks. What would be a good first start for a GPOS rule in my code? (sorry, really no code wizard) I guess I’ll have to force the ligatures 1 or 2 space widths on the left side-bearing every time its used?

And how about making some characters exactly twice the character width (or 3, if necessary). That way it’s technically still monospaced right? It just takes 2 character slots instead.

The question is, if you need a true monospace font at all. That is ‘only’ needed in some situations (for terminals and some linux editors). On Mac, most apps I tied do not really care.

To make a true monospace font:

Draw the glyphs as usual and set the width to the width of the other glyphs. That way, the outline will stick out to the right.

Then add a feature and add code similar to this:

pos some_ligature <0 0 550 0>;

The 550 is the width of the normal glyphs, and of cause you need to double that for glyphs that are three glyphs wide. About the details of the syntax, please check the Adobe feature code spec: https://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#6.a

1 Like

Yes, thank you very much Georg! Works like a charm

This gives me an idea of a new custom “Monospaced” parameter on a font level, which makes sure that all glyph width is identical and adds space-adjusting features to the glyphs which are different from the defined width.

Or maybe you could use that to make sure the spacing won’t change during the design process, even when you generate new glyphs: e.g. if the custom parameter says the width is 560, the new glyphs will be 560. In this case, the ligature glyphs should be able to override the specified width (and the difference will of course be handled automatically).

How about that idea?

2 Likes

Yes, that would be very useful! Don’t know if this would be a problem at all, but the only challenge I can see is; how does Glyphs ‘know’ how to align those ligatures. For example, in my current design some of the ligatures need even triple the monospaced width to align nicely in the context.