Home | News | Download | Packages | Forum | Wiki | Github

Bad font rendering in Firefox for Helvetica


#1

I installed Void Linux Friday on a Thinkpad T470, and everything seems to be in order, but I have a problem in Firefox with the font rendering of Helvetica. Most fonts look nice and sharp while Helvetica looks jagged. The screenshots below show the difference on Github­I made a screenshot using Arial, which I selected by altering the CSS. (The default font on this forum is Helvetica, and the issue also happens here.)

Helvetica: http://i.imgur.com/s0xpIfT.png
Arial: http://i.imgur.com/3PgBKqP.png

My Xft settings in .Xdefaults are as follows:

Xft.autohint: 0
Xft.antialias: 1
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.dpi: 120
Xft.rgba: rgb
Xft.lcdfilter: lcddefault

I have not done a full survey, but Helvetica seems to be the only font that causes the issue.

If anyone has experienced a similar issue and knows how to fix it, let me know.

Vincent


Font rendering: Firefox based browsers
#2

Maybe this is related to the fontconfig update to 2.12.3 (combined with freetype 2.8).


#3

Because this is the bitmap helvetica font from font-adobe-{75,100}dpi, it is useless, buy helvetica or install a different font like dejavu-fonts-ttf or liberation-fonts-ttf.


#4

I have dejavu-fonts-ttf installed, but how do I “replace” Helvetica?


#5

(Replying to myself in case anyone else needs the information)

I copied /etc/fonts/fonts.conf to ~/.fonts.conf and I added the following match pattern:

    <match target="pattern">
        <test name="family" qual="any">
            <string>Helvetica</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>sans-serif</string>
        </edit>
    </match>

Restart Firefox and the ugly, jaggy Helvetica font should be gone and replaced with your default sans-serif font (on my system, this is DejaVu Sans Book by default). Replace sans-serif with the typeface of your choice if you don’t want to use the default, e.g., Ubuntu or Liberation.

You can check that the replacement works by typing fc-match Helvetica at the command-line.


[SOLVED]Firefox - ugly fonts
#6

Just be aware that according to man fonts.conf the location ~/.fonts.conf is deprecated and you should use ~/.config/fontconfig/fonts.conf or ~/.config/fontconfig/conf.d/ for per-user configuration instead.


#7

Is the up-to date freetype and fontconfig version ok? Compared to Lubuntu voidlinux lxde fonts (I selected true-type fonts by the way) look ugly.


#8

Just reinstalled Void i686 lxqt a couple of hours ago, installed firefox-esr-52.6.0_1 and it looks clean, no problem with the fonts.
I have not tested firefox-58.0_1 however.


#9

I installed Void recently and had to do the tweak suggested here, I met the same problem, some fonts looking terrible in Firefox (but not in Qupzilla, which lets me think that it has probably something to do with GTK integration in Plasma).


#10

The real culprit is one of the xorg-fonts, because as soon as I install this metapackage the font rendering gets ugly in firefox-esr. :grimacing:


(nf999) #11

Had the same issue a while back, I added: /etc/fonts/conf.d/00-font-substitute.conf

with

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test qual="any" name="family"><string>Helvetica</string></test>
    <edit name="family" mode="assign" binding="same"><string>sans</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>Times</string></test>
    <edit name="family" mode="assign" binding="same"><string>serif</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>Courier</string></test>
    <edit name="family" mode="assign" binding="same"><string>Courier 10 Pitch</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>Terminal</string></test>
    <edit name="family" mode="assign" binding="same"><string>monospace</string></edit>
  </match>
</fontconfig>

so something similar but system wide.


#12

I found this thread (and post) very helpful a while back, but a heads up in case anyone else runs across the issue.

The solution proposed by @vfoley worked like a charm on Void, but not quite on a couple of other distros I maintain. That snippet of xml appeared unable to override various Helvetica substitutions I had in

/etc/fonts/conf.d/30-metric-aliases.conf

(I had preset substitutions to TeX Gyre on Debian and Nimbus Sans L on Slackware).

fc-match Helvetica

would then still return the substitution from the metric-aliases file. What did work in those cases was replacing the line

<string>sans-serif</string>

with

<string>DejaVu Sans</string>

or whatever you like; Liberation Sans, Cursor, Fixed, DejaVu Mono, etc. These are strings returned by running

fc-list | awk 'BEGIN{FS=":"} {print $2}'

#13

@grobber As I said: removing the xorg-fonts fixed the issue for me.


#14

I understand that and am happy that solution worked out for you, but for my part half the reason of looking into any of this to begin with is to learn something (as a separate goal from the immediate one of resolving the issue itself).

For instance, I’m still puzzled by the behavior reported in my previous post and would like to better understand it: all distros mentioned there have this

30-metric-aliases.conf

file that translates Helvetica to other fonts. For some reason that escapes me at the moment (different fontconfig version perhaps?) that file is superseded by the precise XML snippet in the post by @vfoley on Void, but not on either of the other two distros, which require the font’s “real name” (like DejaVu Sans, as opposed to sans-serif).

If anyone here has any insight into the reason for the difference in behavior, I’d love to have that nut cracked for me.