Several Sites with code editors render numbers in monospace font incorrectly
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
People
(Reporter: hadleym200, Unassigned)
References
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Steps to reproduce:
It seems to affect at least Monaco based editors.
It seems having css triggers it:
font-family: "Droid Sans Mono", "monospace", monospace;
note the quotation marks
this then show in devtools as Noto Sans Color Emoji in devtools
Actual results:
Most code editors render the numbers (in margin, and in body of code) in a bold typeface with colour instead of the font colour.
There are other artifacts like spaces being massive.
The font chosen is Noto Sans Color Emoji
Removing the quotation marks and leaving everthing else the same fixes it and switches font to Noto Sans Mono in devtools
Expected results:
The font selection should be monospace with the correct numbers rendered and colour
The font chosen Noto Sans Mono
| Reporter | ||
Updated•1 year ago
|
Comment 1•1 year ago
|
||
I've tried this on my Ubuntu system, but was not able to reproduce the issue. With the Ubuntu distro version of Firefox (packaged as a snap), I get DejaVu Sans Mono in the Mermaid Live editor; and with a Mozilla build downloaded from mozilla.org, I get Noto Mono.
I suspect this behavior may be dependent on some particular font package that you have installed, which has provided a fontconfig configuration file that inserts Noto Color Emoji into the list of font patterns. It's possible that searching for any mentions of emoji with something like
fgrep -r Emoji /usr/share/fontconfig/
might point towards a culprit. I know there have been some packages that deliberately insert an emoji font early in the list, intending to ensure it gets used for all emoji display, but this can have undesired effects because of characters like the digits (and space!) that really shouldn't be taken from the emoji font unless explicitly requested.
| Reporter | ||
Comment 2•1 year ago
|
||
$fgrep -r Emoji /usr/share/fontconfig
/usr/share/fontconfig/conf.avail/60-generic.conf:<!-- Emoji -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Noto Color Emoji</family> <!-- Google -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Apple Color Emoji</family> <!-- Apple -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Segoe UI Emoji</family> <!-- Microsoft -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Twitter Color Emoji</family> <!-- Twitter -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>EmojiOne Mozilla</family> <!-- Mozilla -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Emoji Two</family>
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Emoji One</family>
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Noto Emoji</family> <!-- Google -->
/usr/share/fontconfig/conf.avail/60-generic.conf: <family>Android Emoji</family> <!-- Google -->
/usr/share/fontconfig/conf.avail/45-generic.conf:<!-- Emoji -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Noto Color Emoji</family> <!-- Google -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Apple Color Emoji</family> <!-- Apple -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Segoe UI Emoji</family> <!-- Microsoft -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Twitter Color Emoji</family> <!-- Twitter -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>EmojiOne Mozilla</family> <!-- Mozilla -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Emoji Two</family>
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Emoji One</family>
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Noto Emoji</family> <!-- Google -->
/usr/share/fontconfig/conf.avail/45-generic.conf: <family>Android Emoji</family> <!-- Google -->
run other fontconfig commands
$fc-match monospace
NotoSans-Regular.ttf: "Noto Sans" "Regular"
$fc-match \"monospace\"
NotoSans-Regular.ttf: "Noto Sans" "Regular"
| Reporter | ||
Comment 3•1 year ago
|
||
Accidently hit Ctrl-Enter
$fc-match monospace
NotoSans-Regular.ttf: "Noto Sans" "Regular"
I do not know the significance of the quote in css other than for including spaces as seen in the attachment unqouting fixed it.
(In reply to hadleym200 from comment #2)
$fc-match monospace NotoSans-Regular.ttf: "Noto Sans" "Regular" $fc-match \"monospace\" NotoSans-Regular.ttf: "Noto Sans" "Regular"
| Reporter | ||
Comment 4•1 year ago
|
||
NotoSansMono-Regular.ttf: "Noto Sans Mono" "Regular"
Comment 5•1 year ago
|
||
The screenshot and the mention of "artifacts like spaces being massive" both remind me of bug 1853595. --> adding as see-also in case there's a relationship...
Comment 6•1 year ago
|
||
I'm almost certain this is somehow related to emoji font configuration, though I'm not sure exactly where it's coming from.
hadleym200, could you please attach copies of the 60-generic.conf and 45-generic.conf files from your system, so I can see if they're in any way different from mine (where I haven't been able to reproduce the problem)? Thanks!
Also, please confirm whether restarting Firefox in Troubleshoot Mode (see the Help menu) makes any difference.
| Reporter | ||
Comment 7•1 year ago
|
||
| Reporter | ||
Comment 8•1 year ago
|
||
| Reporter | ||
Comment 9•1 year ago
|
||
| Reporter | ||
Updated•1 year ago
|
Comment 10•1 year ago
|
||
My suspicion is that this is related to the 56-kubuntu-noto.conf file. (Can you determine what package installed this? I have fonts-noto-color-emoji installed on my Ubuntu system, but I don't see that file or one like it here. But my Ubuntu isn't Kubuntu...)
This contains things like:
<alias>
<family>serif</family>
<prefer>
<family>Noto Color Emoji</family>
<family>Tinos</family>
<family>Noto Serif</family>
...etc
and likewise for sans-serif and monospace.
Note how it's putting the Noto Color Emoji font first in the list of families to "prefer" for the serif generic, ahead of Tinos (presumably a Times clone), Noto Serif, and all the various other-language fonts that follow.
This is a problem, because it means that when we ask fontconfig for the font(s) that serif should resolve to, we get a list that starts with Noto Color Emoji, and as Noto Color Emoji supports the space character and the ASCII digits, that's what gets used to render them. But Noto Color Emoji's space and digits are much wider than they would be in normal text fonts, so they look terrible in context.
If you were to edit that configuration file to put Noto Color Emoji at the end of the list, after the various "real" text fonts, I suspect that would fix the issue. (May require restarting Firefox to ensure it sees the modified setup.)
(I'm not sure why things are configured that way; to me it seems to be asking for trouble, by suggesting that the generic serif, sans-serif, and monospace names should prioritize Noto Color Emoji ahead of normal text fonts.)
Comment 11•1 year ago
|
||
From a bit of searching, it looks like that bad config file may come from a kubuntu-settings package.
It also seems other people have had similar issues, e.g. https://github.com/arkenfox/user.js/issues/1844, https://www.reddit.com/r/kde/comments/1e99j6g/fix_to_noto_emoji_fonts_used_as_letters_and/.
| Reporter | ||
Comment 12•1 year ago
|
||
Try out the fix in the github issue fixes the emoji font issue but font is pulling from the system and not the browser font selection.
Removing the quotation marks in css makes it use the browser monspace font.
I now think that the css is intended as the quotes specifies the fontfamily rather than the generic font of the firefox therefore "monospace" picks a monospace font wheres monospace without quotes uses the generic monospace font of firefox (set in preferences).
Comment 13•1 year ago
|
||
(In reply to hadleym200 from comment #12)
Try out the fix in the github issue fixes the emoji font issue
Great -- thanks for confirming that.
but font is pulling from the system and not the browser font selection.
Removing the quotation marks in css makes it use the browser monspace font.
This sounds like it's behaving correctly. If you use quotation marks, as in font-family: "monospace", then in CSS terms you're asking for a font family that is actually named "monospace". There probably isn't such a font, but we pass the family name you've asked for to fontconfig, and fontconfig is normally set up with various aliases so that a request for the name "monospace" will result in some monospaced font from the packages you have installed.
On the other hand, if you specify font-family: monospace without the quotation marks, then monospace is not interpreted as an actual font family name, but as a CSS generic family, which the browser will resolve according to its settings.
As I understand it, then, there isn't an actual Firefox bug here; there was a badly configured Kubuntu package causing the issue with spacing & digits. The distinction between monospace and "monospace" is expected: as the CSS spec says, "Note that <generic-family> keywords cannot be quoted (otherwise they are interpreted as a <family-name>)".
Are you happy for us to close this issue, or am I missing something that still needs to be investigated/fixed?
| Reporter | ||
Comment 14•1 year ago
|
||
Yes this can be closed
Thanks
Updated•1 year ago
|
Description
•