You are not logged in.

#1 2017-11-01 14:06:21

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Force antialiasing for Firefox

I am running xfce4 and I have antialiasing turned off in Settings -> Appearance -> Fonts because I really prefer pixel-perfect non-antialiased fonts for system menus and other stuff.

However, this turns antialiasing of everywhere. Specifically in Firefox (or Chrome), non-antialiased fonts are ugly. I was wondering if there is a way to enable antialiasing just for specific applications. I have tried some Firefox-specific hacks via about:config, but I couldn't make it work.

Offline

#2 2017-11-01 14:21:00

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

https://www.freedesktop.org/software/fo … -user.html

FONTCONFIG_FILE is used to override the default configuration file.
FONTCONFIG_PATH is used to override the default configuration directory.

Offline

#3 2017-11-01 19:33:29

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

@seth, thanks for your answer! Could you please explain how should I use FONTCONFIG variables to achieve what I want? I don't really understand how the whole thing works between XFCE, fontconfig and the programs.

Offline

#4 2017-11-01 19:37:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

You write a fontconfig file with your desired settings (activated aliasing, otherwise a copy of your local config, I guess)
See https://wiki.archlinux.org/index.php/Fo … figuration

Then try to export the path to this config and start firefox from a shell that has the alternative path exported.

Ultimately you probably want to add a wrapper script that exports the fonconfig path and runs firefox with that path (or simply adjust the desktop service to call "env FONTCONFIG_FILE=/path/to/font.conf firefox")

Offline

#5 2017-11-01 20:23:36

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

I tried changing the antialiasing in XFCE settings, but files in /etc/fonts were not altered (I checked with diff- -r). The setting seems to be in ~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml. This is a XFCE-specific file and does not seem like fontconfig one.

So it looks as if XFCE has some other mechanism in place which bypasses fontconfig? Or am I missing something?

I was hoping to create a separate configuration that would inherit the original and "override" just setting for antialiasing. So for example when I install new fonts, I don't have to manually update other configurations.

Is is still possible to do it like this? Or do I have to make a complete copy of /etc/fonts and maintain it (i.e. copy + patch every time)?

Last edited by bachtiar (2017-11-01 20:29:26)

Offline

#6 2017-11-01 20:31:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

Did you read the link?
$XDG_CONFIG_HOME defaults to ~/.config

Offline

#7 2017-11-01 20:40:17

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

Yes, I've read it, but I don't have per-user fontconfig neither in ~/.config/fontconfig nor in ~/.fontconfig. That's why I'm confused...

Offline

#8 2017-11-01 20:48:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

strace the xfce config dialog - it will write the config somewhere (because fontconfg needs to read it) - maybe the deprecated ~/.fonts.conf* ??

Offline

#9 2017-11-01 21:12:19

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

I did "strace xfce4-appearance-settings" but I'm not sure what I should look for. It opens /etc/fonts/**/*.conf alright, but with O_RDONLY.

It tries ~/.fonts, ~/.config/fontconfig, ~/.local/share/fonts, ~/.fonts, but none of them exist.

It also opens several files in /var/cache/fontconfig/.

The file that is changed by toggling the checkbox is ~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml (found by manual diff -r .config config_old). As I understand, this is part of XFCE settings registry and is managed by xfce-settings. I can see some "sendmsg" in strace output that has the string "Antialias", though. But no clue about how it works with fontconfig.

Last edited by bachtiar (2017-11-01 21:13:13)

Offline

#10 2017-11-01 21:25:01

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

It probably talks to xfsettingsd but I fail to imagine how other (fontconfig driven) clients would pick the settings if it doesn't write the fontconfig files - unless xfce exports it's own FONTCONFIG environment?

env | grep FONTCONFIG

Offline

#11 2017-11-01 21:49:26

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

seth wrote:

It probably talks to xfsettingsd but I fail to imagine how other (fontconfig driven) clients would pick the settings if it doesn't write the fontconfig files - unless xfce exports it's own FONTCONFIG environment?

env | grep FONTCONFIG

No FONTCONFIG either...

Anyway, I tried making a /tmp/fonts.conf like this:

<fontconfig>
  <include>/etc/fonts/fonts.conf</include>
  <match target="font" >
    <edit mode="assign" name="antialias"><bool>true</bool></edit>
 </match>
</fontconfig>

When I start "FONTCONFIG_FILE=/tmp/fonts.conf firefox", it works to a certain extent (i.e. enables antialiasing), but rendering of fonts is notably worse that when I enable antialiasing in XFCE settings. I've also tried giving a value for hinting and hintstyle, but it just isn't the same...

Any ideas?

Last edited by bachtiar (2017-11-01 21:50:40)

Offline

#12 2017-11-01 22:23:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

Autohinter, subpixel rendering, lcd filter ... hard to guess from "notably worse" ;-)

Offline

#13 2017-11-01 22:49:16

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

Yeah, that sucks... I've tried setting those options to what I assume XFCE uses, but no luck so far... Perhaps you know of a program that I could run to display effective fontconfig settings so I could replicate them exactly?

Last edited by bachtiar (2017-11-01 22:49:52)

Offline

#14 2017-11-01 22:54:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

FC_DEBUG=5120 goodlookingxfceclient

This will print the loaded fontconfig files and the applied transformations (but *not* write you an xml pattern)

Offline

#15 2017-11-02 07:36:39

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

That worked. Thanks.

But I'm still puzzled by one thing: how does XFCE communicate effective fontconfig settings to programs?

No XDG_CONFIG_HOME or FONTCONFIG_* variables in environment, no ~/.config/fontconfig, no ~/.fonts.conf, no ~/.fontconfig, no changes in /etc/fonts and no includes from /etc/fonts to anything from XFCE. What the hell?

Could this be something with gtk or even systemd or dbus?

Last edited by bachtiar (2017-11-02 07:38:56)

Offline

#16 2017-11-02 07:43:57

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,114

Re: Force antialiasing for Firefox

I've no idea, but the above command should tell your which config files are read by fontconfig. (Actually "FC_DEBUG=1024" does)
In theory the client could configure fonts directly based on some private configuration, but that sounds like a flawed approach.

Offline

#17 2017-11-02 08:58:42

bachtiar
Member
Registered: 2005-02-08
Posts: 75

Re: Force antialiasing for Firefox

It only prints stuff from /etc/fonts, which I've checked does not change.

According to this article, some programs get their settings directly from xfsettingsd. But it really looks like a mystery. If somebody who can explain this stumbles upon this question, please let me know...

Offline

Board footer

Powered by FluxBB