Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Disable font ligatures in all browsers

As google fonts are blocked in China I had to download them and use FontSquirrel for conversion.

The problem: fi/ff/etc are ugly

I did all of the steps here Prevent ligatures in Safari (Mavericks/iOS7) via CSS but no cigar.

How can I disable ligatures at once? -webkit-font-variant-ligatures: no-common-ligatures; Doesn't work

like image 259
pachadotdev Avatar asked Aug 12 '16 20:08

pachadotdev


People also ask

How do I remove ligatures from font?

In FontForge go to Element > Font Info > Lookups > GSUB. You should be able to select a ligature table there. Then you can click Delete to delete all the ligatures or Edit Data to choose which ligatures to delete. After pressing Edit Data you can select specific ligatures.

What is font variant ligatures?

The font-variant-ligatures CSS property controls which ligatures and contextual forms are used in textual content of the elements it applies to. This leads to more harmonized forms in the resulting text.

What are discretionary ligatures?

A discretionary ligature is more decorative in nature than a standard ligature and should be used at your discretion, as the name indicates. Some discretionary ligatures combine frequently occurring letter pairs (like “Th”) into a single graceful design.

What are common ligatures?

The most common standard ligatures are the f-ligatures: fi, fl, and occasionally ff, ffi, and ffl. These designed letter combinations remedy the unattractive collision that can occur in some typefaces between the hook or crossbar of the f and the dot of the i, or other elements of its neighboring character.


4 Answers

Essentially the same answer that andreas offered, but here's the full CSS for easy reference:

* {
  font-variant-ligatures: none;
}
like image 154
beardofprey Avatar answered Oct 14 '22 06:10

beardofprey


Despite no-common-ligatures you can try values like none, unset or no-contextual . See MDN for all possible values.

For example:

:root {
  font-variant-ligatures: none;
}

Also it should be supported in all modern browsers.

like image 12
andreas Avatar answered Oct 14 '22 05:10

andreas


Seeing no effect in Safari from font-variant-ligatures (see comment on accepted answer above) have used

font-feature-settings: "liga" 0;

which both Safari and Chrome are honouring.

like image 1
SJT Avatar answered Oct 14 '22 06:10

SJT


Not sure why, but I found a situation when Chrome needs both properties:

body {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
}

If set any one of them only, ligatures won't be turned off.

like image 1
Qwertiy Avatar answered Oct 14 '22 06:10

Qwertiy