googlefonts / Inconsolata

Development repo of Inconsolata Fonts by Raph Levien
http://levien.com/type/myfonts/inconsolata.html
SIL Open Font License 1.1
1.32k stars 64 forks source link

How to enable Ligatures in Emacs 28? #58

Open precompute opened 3 years ago

precompute commented 3 years ago

Emacs 28 built with HARFBUZZ supports ligatures via composite ((featurep 'composite) to check)

Using DOOM Emacs , ligatures do not work with Inconsolata (and Ligconsolata) while they work for other fonts (without their specific config flags).

https://github.com/hlissner/doom-emacs/blob/f6f90c9791fa4a5e433bc42af52823bccfe1a362/modules/ui/ligatures/config.el#L174

Since the ligatures are exposed differently, I tried this, but to no avail:

(font-spec :family "Ligconsolata" :size 17 :otf '(latn nil nil (liga))) (font-spec :family "Inconsolata" :size 17 :otf '(latn nil nil (dlig)))

:otf

VALUE must be a list (SCRIPT-TAG LANGSYS-TAG GSUB [ GPOS ]) to specify
required OpenType features.

  SCRIPT-TAG: OpenType script tag symbol (e.g. deva).
  LANGSYS-TAG: OpenType language system tag symbol,
     or nil for the default language system.
  GSUB: List of OpenType GSUB feature tag symbols, or nil if none required.
  GPOS: List of OpenType GPOS feature tag symbols, or nil if none required.

GSUB and GPOS may contain nil elements.  In such a case, the font
must not have any of the remaining elements.

For instance, if the VALUE is (thai nil nil (mark)), the font must
be an OpenType font whose GPOS table of thai script's default
language system must contain mark feature.

Modifying a Customize entry:

(custom-set-faces
 '(default ((t (:family "Inconsolata"
                :otf '(latn nil nil (dlig))
                )))))

Does not work either.

I'd preferably sort this out in vanilla Emacs first, but I've had no luck there either.

Any help is appreciated!

precompute commented 3 years ago

I've managed to sidestep the problem using https://github.com/ToxicFrog/Ligaturizer

It inserts ligatures from Fira Code into the target font. Fira Code's ligatures work without any extra configuration, and the same inserted into Inconsolata also work well. It does looks jarring, but I have turned off most 2/3 repeating character ligatures. I had to turn off the -- ligature because it interfered with dired. The remaining arrows and gt / lt signs look fairly okay.