masm11 / emacs

Mirror of GNU Emacs
http://www.gnu.org/software/emacs/
GNU General Public License v3.0
198 stars 14 forks source link

Ligatures support #82

Closed rainDiX closed 3 years ago

rainDiX commented 3 years ago

Ligatures do not render when using emacs pgtk

emacs pgtk For comparison, here it is how it render using emacs vanilla (a bit blurry because of xwayland's scaling). emacs vanilla

How to reproduce

My environment

archlinux gtk3 3.24.23 cairo 1.17.2 harfbuzz 2.7.2 sway 1.5.1

masm11 commented 3 years ago

I can't enable ligatures on X-build.

  1. Install Fira Code font.
  2. Build X-emacs.
  3. ./src/emacs -Q
  4. evaluate (set-fontset-font nil nil "Fira Code").
  5. load ligature.el and evaluate it.
  6. evaulate commented config snippet.
  7. I typed "www" on some buffers. It is not ligatured.

What's wrong?

rainDiX commented 3 years ago

To enable ligatures I do as follows ( Keep steps 0, 1 and 2):

  1. evaluate (set-face-attribute 'default nil :font "Fira Code").
  2. load ligature.el and evaluate it.
  3. evaluate (ligature-set-ligatures 't '("www")) (ligature-mode 1)
  4. www should be ligatured
rainDiX commented 3 years ago

Or alternatively, without needing ligature.el at all :

  1. evaluate
    
    (set-face-attribute 'default nil :font "Fira Code")
    (let ((ligatures `((?w  . ,(regexp-opt '("www")))
         (?&  . ,(regexp-opt '("&&&" "&&"))))))
    (dolist (char-regexp ligatures)
    (set-char-table-range composition-function-table (car char-regexp)
                          `([,(cdr char-regexp) 0 font-shape-gstring]))))

4. "www" "&&" and "&&&" should be ligatured
masm11 commented 3 years ago

thank you. confirmed.

masm11 commented 3 years ago

I forgot to register harfbuzz font driver. I registered it, and now ligatures work.

Try latest feature/pgtk on savannah.

lig

rainDiX commented 3 years ago

Tested the newer commit, that fixed it. Thanks.