Closed Bug 1545350 Opened 6 years ago Closed 6 years ago

Available monospace Font gets ignored and falls back to the 3rd font on font-family font stack

Categories

(Core :: Layout: Text and Fonts, defect)

66 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: lin.subscriber, Unassigned)

Details

(Keywords: fonts)

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0

Steps to reproduce:

On GitHub page, the code block is styled with

font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;

I have SFMono installed on the system, however, Liberation Mono is used instead.

If I update the CSS value to

font-family: SF Mono;

Or

font-family: SF Mono,Consolas,Liberation Mono,Menlo,Courier,monospace;

It would work properly.

What is wrong with my setup?

Below are 2 command outputs:

$ fc-match -s 'SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace' | head -2

SFMono-Regular.otf: "SF Mono" "Regular"

DroidSans.ttf: "Droid Sans" "Regular"

$ fc-match -s 'SFMono-Regular' | head -2

SFMono-Regular.otf: "SF Mono" "Regular"

DroidSans.ttf: "Droid Sans" "Regular"

Actual results:

Liberation Mono is used instead.

Expected results:

SF Mono-Regular should be used in this case.

Attached image GitHub current Style
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Keywords: fonts

Add the config below makes it work.

<alias>
  <family>SFMono-Regular</family>
  <prefer><family>SF Mono</family>
  </prefer>
</alias>

Is this really neccessary?

I cannot reproduce this issue on Ubuntu 16.04 x64, with standard font packs and no tweaks I remember of. Could you please add the OS version you are experiencing this issue on?
It would be also be useful to do a quick check on a different browser in order to verify if the problem is indeed Firefox related or system related.

Let's triage this issue for now to Core::Layout::text and fonts in order to get somebody with a better understanding of this involved.

Component: Untriaged → Layout: Text and Fonts
Product: Firefox → Core

(In reply to lin.subscriber from comment #0)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0

Steps to reproduce:

On GitHub page, the code block is styled with

font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;

SFMono-Regular is not a valid font-family name; it's the PostScript name of an individual font face. The CSS font-family property expects font family names, not font face names.[1]

(Note that some browsers behave incorrectly here, e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=641861.)

The correct CSS would be font-family: "SF Mono", Consolas, ....

The fontconfig tweak (comment 4) works around the incorrect CSS by aliasing the font-family name, but the correct solution is to fix the CSS.

So not a Firefox bug.

[1] https://www.w3.org/TR/css-fonts-3/#font-family-prop

Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: