build-emacs-for-macos icon indicating copy to clipboard operation
build-emacs-for-macos copied to clipboard

How to compile with Harfbuzz and Cairo?

Open mateusfccp opened this issue 2 years ago • 10 comments

I am using build-emacs-for-macos for a while and it's really nice.

However, I didn't manage to compile with Cairo and Harfbuzz. They should be default, but even if I explicitly pass --with-harfbuzz and --with-cairo to configFlags it won't be compiled with them.

How may I compile with Harfbuzz and Cairo?

mateusfccp avatar Sep 03 '21 12:09 mateusfccp

It looks like harfbuzz and cairo support for macOS is rather recent. Last I looked into it about a year ago it was not possible.

However emacs-plus supports it as of 6 weeks ago, so I'll try and get support added to build-emacs-for-macos here this weekend :)

jimeh avatar Sep 03 '21 12:09 jimeh

Yes, at first I thought that it was not supported, but then I saw this issue from emacs-plus. I don't know, however, what has to be done.

I'll try and get support added to build-emacs-for-macos here this weekend :)

Thanks!

mateusfccp avatar Sep 03 '21 12:09 mateusfccp

Actually, it seems harfbuzz and cairo support has been removed from emacs-plus as it turns out they yield no advantage over macOS's own CoreText renderer, which is why upstream emacs itself does not support it on macOS. More details here: https://github.com/d12frosted/homebrew-emacs-plus/pull/371#issuecomment-881976323

As such, I don't think there's much point in porting over the now removed patch from emacs-plus. @mateusfccp please let me know if you would still like the ability to try harfbuzz and cairo on macOS out of curiosity, cause then I'm happy to spend the 5-10 minutes required to get it working :)

jimeh avatar Sep 03 '21 12:09 jimeh

@jimeh My main use-case for this is to enable font ligatures, which, AFAIK, is not supported through CoreText, but I may be wrong...

mateusfccp avatar Sep 03 '21 13:09 mateusfccp

Well, reading the comment you linked, the author seems to be able to enable ligatures without Harfbuzz, although I have no idea how.

mateusfccp avatar Sep 03 '21 13:09 mateusfccp

Yeah, indeed. I've never tried using ligatures myself. I'll give it a go this weekend and see what I can find :)

jimeh avatar Sep 03 '21 21:09 jimeh

@mateusfccp @jimeh FYI, I just tested using ligatures via ligature.el with the latest Emacs master and Emacs 28 builds from emacs-builds and it works fine without any additional steps, though the rendering isn't quite perfect, at least with the latest Fira Code font.

ligature-mode disabled: image

ligature-mode enabled: image

schellj avatar Oct 29 '21 20:10 schellj

@schellj Neat, I never got around to testing it myself. But I'm gonna try and get a number of outstanding things resolved over the next few weeks, so I'm gonna try ligatures myself. And I'll also try and get a build with harfbuzz/cairo and see how it compares.

jimeh avatar Oct 29 '21 20:10 jimeh

@schellj Thanks! I am almost sure I did try ligatures.el before but it didn't work. I am going to give it another try!

mateusfccp avatar Nov 02 '21 10:11 mateusfccp

FWIW, it looks like the non-perfect rendering of the ligatures in my previous comment may just be due to that particular font (Fira Code). JetBrains Mono does a better job (e.g., you can't see where characters have been merged in spaceship (<=>), fat comma (=>) and arrow (->)): image

schellj avatar Nov 08 '21 22:11 schellj