Open Bug 1406790 Opened 3 years ago Updated 3 years ago

When "Open Sans" is specified by web-pages, "Comfortaa" is used instead.


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

56 Branch





(Reporter: wainwrighthugo, Unassigned)



(Keywords: regression)


(4 files)

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0
Build ID: 20171004085519

Steps to reproduce:

Open a page with a text element which has its font-family set to "Open Sans".

Actual results:

Instead of displaying the "Open Sans" font, the "Comfortaa" font is displayed instead.

Expected results:

The "Open Sans" font should be displayed.
Component: Untriaged → Layout: Text
Product: Firefox → Core
Do you have the Open Sans fonts installed on your system? What does

    fc-match :family="Open Sans"

return when run in a terminal window?
Flags: needinfo?(wainwrighthugo)
Ah! It does indeed seem to return

    Comfortaa-Regular.ttf: "Open Sans" "Regular"

I suppose something is wrong with my system, apologies for the false alarm!
Hmmm, looks like the I spoke too soon. The font being returned in the above call there was a copy of OpenSans-Regular.ttf I had renamed to Comfortaa-Regular.ttf and placed in my local fonts directory in order to try and circumvent this issue. Once I had removed it, fc-match :family="Open Sans" correctly returns with

    OpenSans-Regular.ttf: "Open Sans" "Regular"

whilst FireFox is still rendering the incorrect font.
Flags: needinfo?(wainwrighthugo)
Did you exit and restart Firefox after removing the local font? Does the problem persist if you run it with a fresh profile?
Yes, on both counts.
Strange, I don't know what's happening here.

Does Open Sans show up in the list of available fonts in Preferences?

Trying a minimal testcase such as

    data:text/html,<div style="font-family: Open Sans">Hello world does this display?

What does the DevTools Inspector show in the Fonts panel (i.e. not the font-family property shown under Rules, but the actual font used)? Note that the Fonts panel may not be visible by default (it's beyond Animations), you might need to choose it from the drop-down arrow menu.
Flags: needinfo?(wainwrighthugo)
I've attached a screenshot of how it the minimal test case displays for me. The actual font used is shown to be Comfortaa.
Flags: needinfo?(wainwrighthugo)
OK, that's clearly wrong! So, does Open Sans show up at all in the Firefox font list (in Preferences)?

How was the Comfortaa font installed on your system -- is it provided by a distro package, or what's the source of this font? Somehow it seems to be getting used as a substitute for Open Sans, which implies something weird about the fontconfig setup.
Flags: needinfo?(wainwrighthugo)
Open Sans is available as a default font, and when I deselect the check box allowing web-pages to supply their own fonts and force them all to use Open Sans, then it displays correctly.

Both Open Sans and Comfortaa came pre-installed as part of my distro.
Flags: needinfo?(wainwrighthugo)
Firefox is the only application which exhibits this behaviour; visiting the same pages in an alternative browser correctly displays the text in Open Sans.
(In reply to Hugo Wainwright from comment #11)
> Firefox is the only application which exhibits this behaviour; visiting the
> same pages in an alternative browser correctly displays the text in Open
> Sans.

This is probably because Firefox tries to follow any font aliasing, substitutions, etc., that are specified in the fontconfig setup, whereas I believe most other browsers ignore this.

Could you see what specific configuration file(s) mention these fonts? Depending on your distro, I guess they may be in /etc/fonts/conf.d/ or something like that.... perhaps running

    fgrep -r -i -l "comfortaa" /etc/fonts
    fgrep -r -i -l "open sans" /etc/fonts

would find the relevant files. I'm particularly interested in the .conf files that mention either/both of these families.
Flags: needinfo?(wainwrighthugo)
I've actually already checked in my font configs to see if anything was amiss, but I couldn't find anything. The only configs I could find that are referencing either of those fonts are just "60-open-sans.conf" and "61-aajohan-comfortaa.conf", both of which have innocuous-looking contents.
Flags: needinfo?(wainwrighthugo)
Attached file 60-open-sans.conf
I'm not a fontconfig expert, but from my (naïve) reading of those files, I think they do explain the problem.

First, 60-open-sans includes:

    <family>Open Sans</family>

which says that when the family name "Open Sans" is requested, we should *prefer* the generic family "sans-serif". It then goes on to offer Open Sans as a default to fulfill the sans-serif generic, but that's secondary, because in 61-aajohan-comfortaa we find:


which says that for the generic family "sans-serif", we are to *prefer* using Comfortaa.

So I think Firefox is following the chain of "prefer" aliases here, and the problem arises because of the different ways the two families are configured. Open Sans is trying to be rather self-effacing, telling us to prefer the generic even if Open Sans was specifically requested; while Comfortaa is proactively trying to get itself used as the *preferred* family to resolve sans-serif. So it wins.

I'd say this looks like a bug in the configuration of your distro's font packages.
cc'ing Karl, who is much more experienced with fontconfig than I am, and may be able to clarify further (or correct me if I'm entirely misunderstanding things here).
Ah! Removing the former alias (the one which causes Comfortaa to be preferred over the generic sans-serif) in 61-aajohan-comfortaa.conf seems to resolve the problem!

I do suspect, however, that Firefox may be behaving in a slightly deviant way here, considering that the resolution results in a different result to fc-match.

Nonetheless, many thanks for resolving the issue for me!
(In reply to Hugo Wainwright from comment #18)
> I do suspect, however, that Firefox may be behaving in a slightly deviant
> way here, considering that the resolution results in a different result to
> fc-match.

Yes, that does seem curious. Karl, do you have any insight here?
Flags: needinfo?(karlt)
Perhaps this is due to gfxFcPlatformFontList::FindAndAddFamilies() not being able to distinguish between strong and weak bindings of families.  IIRC aliases have weak binding by default and strong families have priority over weak families, even when the language matches.

I agree the prefer aliases are strange, and I actually also find strange the fontconfig behavior to choose strong families over preferred weak families, even when the language matches.
Blocks: 1056479
Flags: needinfo?(karlt)
Keywords: regression
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.