Solved Ugly fonts on some websites.

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#1
Hi!

First, I already look on several places for similar situations, and none of the solutions worked for me.

Since yesterday I began to experiment some ugly fonts on www/firefox at some sites, I believe it is more related with websites that rely more on javascript - but I am not a web developer.

I know if I disable the fontconfig bitmap font support the problem is gone, but I wont do that because my entire desktop rely on the ohsnap font, and everything was properly working before. :mad:

I tried some others browsers and just www/midori seem to not have this problem. Or it is more discrete, maybe.

Also, it is inconsistent sometimes. In github, some pages the "README.md" text is affected and others not, as can be seen here.

I do not have ~/.config/fontconfig/.fonts file, but I tried creating one and tested with several different configurations what changed nothing in relation with the problem. Indeed, modifying anything bellow also did not change anything related with the problem.

cat .Xresourses
Code:
Xft.rgba:    rgb
Xft.hintstyle:    hintslight
Xft.lcdfilter:    lcddefault
Xft.dpi:    96
Xft.antialias:    1
Xft.hinting:    1
Xft.autohint:    0
ls /usr/local/etc/fonts/conf.d
Code:
10-autohint.conf           30-urw-aliases.conf        51-local.conf              80-delicious.conf
10-hinting-slight.conf     31-cantarell.conf          60-latin.conf              90-synthetic.conf
10-scale-bitmap-fonts.conf 40-nonlatin.conf           65-fonts-persian.conf      README
11-lcdfilter-default.conf  45-latin.conf              65-nonlatin.conf
20-unhint-small-vera.conf  49-sansserif.conf          69-unifont.conf
30-metric-aliases.conf     50-user.conf               70-yes-bitmaps.conf
Changing the browser fonts in its configurations do nothing in relation to the problem. I also tried to recreate the font cache, and nothing.

Thanks!
 
OP
OP
Rigoletto

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#2
Little advance. The uglyness happens when the website wants Helvetica and/or Times.

When it wants Helvetica, it is using "system: Helvetica" what is not being anti-aliased probably because I do not have that font installed anywhere in the system.

More or less the same happens with "Times". However, if I install x11-fonts/webfonts the "Times" problem disappear - but not the "Helvetica" one.

I use x11-fonts/croscorefonts-fonts-ttf instead of x11-fonts/webfonts, and the aliases were working pretty well.

As far I understand Helvetica/Arial should be aliased to "Arimo", and Times to "Tinos", but it is not and indeed it bring another problem. I have "Tinos" installed (croscorefonts) but that font do not appear as option anywhere... I cannot set it in Firefox or Texstudio, or anything...
 
OP
OP
Rigoletto

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#3
pkg check -Bsdr
Code:
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/57-dejavu-sans-mono.conf
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/57-dejavu-sans.conf
dejavu-2.37: missing file /usr/local/etc/fonts/conf.d/57-dejavu-serif.conf
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf): No such file or directory
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf): No such file or directory
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf): No such file or directory
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/57-dejavu-sans-mono.conf): No such file or directory
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/57-dejavu-sans.conf): No such file or directory
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/57-dejavu-serif.conf): No such file or directory
Checking all packages:  12%
font-bh-ttf-1.0.3_3: missing file /usr/local/etc/fonts/conf.d/42-luxi-mono.conf
pkg: fstat() failed for(/usr/local/etc/fonts/conf.d/42-luxi-mono.conf): No such file or directory
Checking all packages: 100%
EDIT: reinstalling x11-fonts/dejavu and x11-fonts/font-bh-ttf made the errors disapear but the problem persist.

Trying pkg upgrade -f.
 
OP
OP
Rigoletto

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#5
Ok, x11-fonts/font-adobe-100dpi is the guilty, as it brings Helvetica and Times Bipmap fonts, what are messing with the browser fonts.

Now I have to think of I will do about it. ;)

EDIT: IIRC there is a way to blacklist fonts with fontconfig... and probably Tinos was blacklisted for unknown reason
 
Last edited:
OP
OP
Rigoletto

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#6
Creating

~/.config/fontconfig/fonts.conf
Code:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>

    <dir>~/.fonts</dir>

    <!--    do not use the embedded bitmap instead of the outline
        <https://www.freebsd.org/cgi/man.cgi?query=fonts-conf&sektion=5&manpath=FreeBSD+and+Ports>
        <https://bbs.archlinux.org/viewtopic.php?id=161609> post 2 (2013)
        <https://redd.it/7kqr5l> (2017) -->
    <match target="font">
        <edit name="embeddedbitmap" mode="assign">
            <bool>false</bool>
        </edit>
    </match>

    <!--    prefer outline e.g. TrueType instead of bitmap fonts
        <https://bbs.archlinux.org/viewtopic.php?id=161609> post 2 (2013)
        <https://redd.it/4tb2dt> (2016) -->
    <match target="font">
        <edit name="prefer_outline">
            <bool>true</bool>
        </edit>
    </match>

    <!--    reject bitmap fonts, except Ohsnapu - prefer PostScript, TrueType et cetera
        <https://forums.freebsd.org/threads/howto-nice-fonts.2021/> (2009)
        <https://redd.it/4tb2dt> (2016) -->
    <selectfont>
        <acceptfont>
            <pattern>
                <patelt name="family">
                    <string>Ohsnapu</string>
                </patelt>
            </pattern>
        </acceptfont>
        <rejectfont>
            <pattern>
                <patelt name="scalable">
                    <bool>false</bool>
                </patelt>
            </pattern>
        </rejectfont>
    </selectfont>

</fontconfig>
did the trick. \o/

UPDATE: I updated the file contents based on the research made by grahamperrin about the same subject. :D
 
Last edited:

drhowarddrfine

Son of Beastie

Thanks: 925
Messages: 2,806

#7
Hmm. I don't have that but I have Helvetica and Times which I installed from ports long ago. Yes, if the system doesn't have the font called for by a web site, it will not use it or the browser will download it and use it if the site supplies the font.
 
OP
OP
Rigoletto

Rigoletto

Daemon
Developer

Thanks: 748
Messages: 1,654

#8
Hi!

The problem was, for some reason (it was working before), some sites kept using the Bipmap fonts - I wasn't aware of them being installed. One time I discovery what the problem was I could just had installed Helvetica as I have tons of fonts stored here. Indeed I think I have more than one type of Helvetica, but I won't do it for two reasons: it was working before without Helvetica being installed, and I do not like to have "extra" fonts installed for no reason because it can be painful to find a font in the list when we need it.

I have the x11-fonts/noto installed, and it is a annoying already to have to pass to the tons of versions of it. However, it still better than do not the characters for some unknown language. :)

The good part, I learned something about fonts in websites. :beer:
 
Last edited:

chrischimp

New Member

Thanks: 2
Messages: 9

#9
Creating

~/.config/fontconfig/fonts.conf
Code:
<selectfont>
    <rejectfont>
        <pattern>
            <patelt name="family" >
                <string>Helvetica</string>
            </patelt>
        </pattern>
    </rejectfont>
</selectfont>

<selectfont>
    <rejectfont>
        <pattern>
            <patelt name="family" >
                <string>Times</string>
            </patelt>
        </pattern>
    </rejectfont>
</selectfont>
did the trick. \o/
This did the trick for me too, this is a much more pleasant experience for me now. :beer:
 

aragats

Aspiring Daemon

Thanks: 362
Messages: 921

#12
I came to a situation when simply rejecting "bad" fonts does not help. Especially with Microsoft fonts, which I have to use to correctly display corporate emails etc.
The problem is that certain TTF fonts contain bitmaps as well, they are supposed to be used with small sizes. However, they look very ugly both in browsers and email clients.
The solution is to disable embedded bitmaps in ~/.fonts.conf:
XML:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
        <match target="font">
                <edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>
        </match>
</fontconfig>
According to the handbook the mentioned above ~/.config/fontconfig/fonts.conf file should be used, I just have my ~/.fonts.conf for long time, and it still works.
 
Last edited by a moderator:

alias

New Member


Messages: 9

#13
I came to a situation when simply rejecting "bad" fonts does not help. Especially with Microsoft fonts, which I have to use to correctly display corporate emails etc.
The problem is that certain TTF fonts contain bitmaps as well, they are supposed to be used with small sizes. However, they look very ugly both in browsers and email clients.
The solution is to disable embedded bitmaps in ~/.fonts.conf:
Code:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
        <match target="font">
                <edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>
        </match>
</fontconfig>
According to the handbook the mentioned above ~/.config/fontconfig/fonts.conf file should be used, I just have my ~/.fonts.conf for long time, and it still works.

My ~/.fonts.conf and my ~/.config/fontconfig both have this, except the path has been shortened to ~/ to protect the ignorant (me):

XML:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

<!--
    This file is maintained by Font Manager.

    If you wish to make any changes it is suggested you do so using

       ~/.config/font-manager/local.conf

    Any changes made to this file will be automatically relocated there
    at startup and any settings already in that file will be overwritten.
-->

    <include ignore_missing="yes">~/.config/font-manager/conf.d</include>
    <include ignore_missing="yes">~/.config/font-manager/directories.conf</include>
    <include ignore_missing="yes">~/.config/font-manager/local.conf</include>
    <include ignore_missing="yes">~/.config/font-manager/select.conf</include>

</fontconfig>
I tried putting your code in ~/.config/font-manager/local.conf, and reverting back to the original ~/.config/fontconfig/fonts.conf from before I added lebarondemerde's changes, and the appearance was better but still pretty ugly and hard to read at the 14px that the website I was looking at has it set to (verticals too close together). So, I put it back the way it was with lebarondemerde's changes, since I don't have to worry about corporate emails looking accurate right down to the font used. I have no idea what font it's actually using now, but at least I can read it.

But the comment in the file(s) above is confusing to me, because it says that changes should be added to ~/.config/font-manager/local.conf, but it also says that that file will be overwritten next reboot, with the file that the comment is warning you against editing. (Or "at startup", whatever startup that's referring to, maybe xorg?) ?? Some kind of this/that mixup?

I do not have a ~/.config/font-manager/local.conf file, so if one gets created with the contents of ~/.config/fontconfig/fonts.conf, I guess that's ok.

I haven't rebooted to see if that's true, or what happens, but I did make a copy of my changed ~/.config/fontconfig/fonts.conf just in case it disappears on reboot (or xorg restart).

Edit: Maybe I need to add your code too, so it helps with other fonts I may not have noticed yet. Hmmm...
 
Last edited by a moderator:

michael_hackson

Active Member

Thanks: 80
Messages: 147

#15
How is this marked as solved?

What was the solution to this?
- - - - -

Creating

~/.config/fontconfig/fonts.conf
Code:
<selectfont>
    <rejectfont>
        <pattern>
            <patelt name="family" >
                <string>Helvetica</string>
            </patelt>
        </pattern>
    </rejectfont>
    <rejectfont>
        <pattern>
            <patelt name="family" >
                <string>Times</string>
            </patelt>
        </pattern>
    </rejectfont>
</selectfont>
did the trick. \o/
Maybe the author himself should reply to you but since I am online I can do it. As he stated, the problem came from fonts matching "Helvetica" and "Times" so he created the mentioned ~/.config/fontconfig/fonts.conf and put the XML coding in there to simply reject (disable) the fonts matching the pattern "Helvetica" and "Times", forcing other fonts to be used in their place.
 
Top