IdreesInc / Monocraft

A monospaced programming font inspired by the Minecraft typeface
https://monocraft.idreesinc.com
SIL Open Font License 1.1
8.41k stars 121 forks source link

Make ligatures "monospaced" and use complex character substitution #77

Open IdreesInc opened 1 year ago

IdreesInc commented 1 year ago

The ligature characters used in Monocraft replace multiple characters and so are bigger than the other characters in the font. This causes the font to not technically be classified as a monospaced font on Mac. Fonts like Hasklig and FiraCode use complex character substitution that replace the characters with ligature glyphs that go beyond the bounds and spacer characters to match the width of the original character set. I am not sure how to reproduce this in FontForge and it seems to be complicated, so any help on how to replace multiple characters (like "===") with other multiple characters (like "[SPACE][SPACE][LIG]") would be appreciated!

speelbarrow commented 1 month ago

For anyone looking for a workaround, I seem to have stumbled upon one here:

Run FontForge. Go to File > Open to load the font. Go to Edit > Select > Glyphs with only References (while holding Shift). Go to Edit > Select > Glyphs with only Splines (while holding Shift). Go to Metrics > Set Width To: (insert value)* then select Center in Width. Go to Field > Generate Fonts. Generate.

Use the width automatically provided in the "Set Width To" dialog.

CAVEATS:


Attached is a zip file of all the weights after going through this process, should work if you're on macOS and need an actually monospaced font.

MonocraftMono.zip

Dheatly23 commented 3 weeks ago

@speelbarrow That doesn't work for ligatures though, because ligature character width must be the same as the entire substring width.

I'll see what i can do.

speelbarrow commented 3 weeks ago

@speelbarrow That doesn't work for ligatures though, ...

@Dheatly23 Okay, but, counterpoint: I tried it and they still work (sometimes)

Screenshot 2024-10-20 at 11 28 27 AM
Neovide v0.13.3



Screenshot 2024-10-20 at 11 28 20 AM
Kitty v0.36.4



Kitty has always been a bit weird about ligatures (in my experience, at least), so I'd take that second screenshot with a grain of salt as well. Obviously this is not a full solution to this issue, but perhaps it's a start? I'm by no means a font developer so I'll defer to the judgment of others on this one. Just thought I'd chime in with what I've already tried.