Open Bug 1406790 Opened 3 years ago Updated 3 years ago
When "Open Sans" is specified by web-pages, "Comfortaa" is used instead
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.
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?
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.
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 ...how 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.
I've attached a screenshot of how it the minimal test case displays for me. The actual font used is shown to be Comfortaa.
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.
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.
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.
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.
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: <alias> <family>Open Sans</family> <prefer> <family>sans-serif</family> </prefer> </alias> 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: <alias> <family>sans-serif</family> <prefer> <family>Comfortaa</family> </prefer> </alias> 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?
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.
You need to log in before you can comment on or make changes to this bug.