eigilnikolajsen / commit-mono

Commit Mono is an anonymous and neutral programming typeface.
https://commitmono.com/
1.14k stars 16 forks source link

Smart Kerning doesn't seem to work in Emacs #8

Closed msuess closed 10 months ago

msuess commented 12 months ago

First of all: thank you for creating this awesome font! 🙏

I have downloaded the font with "Smart Kerning" enabled, however it doesn't seem to do anything in Emacs. How is this implemented? Are there any special ligatures that need to be enabled for this to work?

eigilnikolajsen commented 12 months ago

Have you looked into Fira Code's guide to Emacs? Commit Mono's ligatures are structered the same way as Fira Code, so they should work in the same way. Tell me if they don't.

msuess commented 12 months ago

They don't. I don't see any ligatures, but arrows are working.

eigilnikolajsen commented 12 months ago

Smart kerning is pretty subtle, so it can be hard to tell if it is on. Can send me a screenshot of this text: "Commit Mono => -> <= ... "

zovt commented 11 months ago

I think unfortunately the current "state of the art" when it comes to enabling ligatures in Emacs is the ligature.el package. But unfortunately, that a) doesn't allow you to enable stylistic sets and b) requires you to manually list out each ligature you want enabled.

I'm not sure how easy this would be, but if possible, if we could get a listing of all character runs that have ligatures associated, that would make it easiest for us Emacs users to enjoy the smart kerning feature here. But I totally understand if that's too much work / not possible.

Thanks in advance :) beautiful font!

eigilnikolajsen commented 11 months ago

I really have no idea how Emacs works, but you can see the Smart Kerning feature code here.

zovt commented 11 months ago

Yep, I ran across that code while looking through this as well. Unfortunately, there (to my knowledge) is not a straightforward way to enable entire stylistic sets in Emacs.

So ideally we'd need a full, static listing of ligatures (i.e. we'd need a list of character sets to apply ligation to, for example from the website: 'moi', 'typ', etc.). I have no idea what that code ends up generating internally in the font, but if there is a way to pull all of the character sets from that stylistic set, we could use that I think.

That said, I have no idea where to even start with something like that, so no worries if that's not something you want to deal with!

eigilnikolajsen commented 11 months ago

To my ears it sounds as though it is not possible. This is because the Smart Kerning feature uses contextual substitution and what you're talking about is simple change all 'G' for another 'G' for example. Correct me if I'm wrong.

zovt commented 11 months ago

I wouldn't say the logic is "substitute every G for another G", but rather "when you see the string of characters '=>', render it using the glyph that looks like '⇒'".

So in essence, there's a lookup table that maps from sets of characters to glyphs, which unfortunately as of now Emacs requires the user to manually construct.

Now, from my read of the code you linked it appears to be some sort of dynamic set of rules that could possibly be compiled into such a table, but again I have no clue of how these things work in a font so it's possible that such a table does not exist internally.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/OpenType_fonts_guide#discovering_availability_of_features_in_fonts lists some resources for mucking about with fonts and discovering features. I'll have a go with tossing the files in there to see if I get anything close to what I'm looking for out

But even if what I'm looking for isn't reasonably possible, I appreciate you taking the time to discuss! This may end up driving me to take a look at how Emacs is using harfbuzz internally to see if I can convince it to work with stylistic sets instead of the manual madness we currently have to deal with.

eigilnikolajsen commented 11 months ago

Interested to see what you find out. Good luck.

eigilnikolajsen commented 11 months ago

Not sure where to go with this issue. Can I close it?

listx commented 10 months ago

It's probably worth clarifying that this issues is only for GUI emacs. I use wezterm+emacs (terminal emacs), so wezterm does all of the smart kerning very nicely and emacs doesn't have to do anything.

eigilnikolajsen commented 10 months ago

I believe this is not an issue I can solve, since it probably isn't related to the font. Reopen if you think I should do something about it!

stevemolitor commented 7 months ago

I got smart kerning to work with Emacs as described here.

eigilnikolajsen commented 7 months ago

Amazing work!