Bug 268668 - x11-themes/classiclooks unduly force fontconfig antialias settings
Summary: x11-themes/classiclooks unduly force fontconfig antialias settings
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-desktop (Team)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-31 11:26 UTC by Bertrand Petit
Modified: 2023-01-05 21:51 UTC (History)
3 users (show)

See Also:
fbsd: maintainer-feedback+


Attachments
Screenshot of the test program runing on the affected host (2.77 KB, image/png)
2022-12-31 11:26 UTC, Bertrand Petit
no flags Details
Screenshot of the test program runing on the unaffected host (1.67 KB, image/png)
2022-12-31 11:27 UTC, Bertrand Petit
no flags Details
Test program used to produce the two screenshots (3.87 KB, text/plain)
2022-12-31 11:28 UTC, Bertrand Petit
no flags Details
Makefile that can be used to build the test program (260 bytes, text/plain)
2022-12-31 11:29 UTC, Bertrand Petit
no flags Details
patch to update port from 2.2.0 to 2.2.0_1 (1.60 KB, patch)
2023-01-04 22:13 UTC, J.R. Oldroyd
no flags Details | Diff
patch to update port from 2.2.0 to 2.2.0_1 with conf.d link (1.82 KB, patch)
2023-01-04 23:18 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bertrand Petit 2022-12-31 11:26:13 UTC
Created attachment 239148 [details]
Screenshot of the test program runing on the affected host

I recently did a full system upgrade that brought fontconfig 2.14.0 in, since then I observed that my reading ability is impeded. I rooted this to fontconfig which no longer honor lcdfilter settings in fonts.conf. I can't remember when I disabled LCD filtering to improve text display, for maybe ten years I have the followinf lines in ~/.config/fontconfig/fonts.conf file:

    <!--  Disable sub-pixel rendering but we still use antialias -->
    <match target="font">
        <edit mode="assign" name="rgba">
            <const>none</const>
        </edit>
	<edit mode="assign" name="lcdfilter">
	  <const>lcdnone</const>
	</edit>
        <edit mode="assign" name="antialias">
            <bool>true</bool>
        </edit>
    </match>
    <!-- Enable hinting when provided by the font -->
    <match target="font">
        <edit mode="assign" name="hinting">
            <bool>true</bool>
        </edit>
        <edit mode="assign" name="hintstyle">
            <const>hintfull</const>
        </edit>
        <edit mode="assign" name="autohint">
            <bool>true</bool>
        </edit>
    </match>

I initially thought this might be caused by toolkits forcing lcdfilering on so I wrote a small test program using only xlib and xft. Despite the settings shown above, even using this basic display interface the characters rendered through xft are lcdfiltered and came to the conclusion that the culprit is either fontconfig or xft (the former is more probable).

To support my claim, I join the test program and two screenshots, made on the same display server, of two instances of the same test client running on two different hosts. Please note that the unaffected host is remote.
Comment 1 Bertrand Petit 2022-12-31 11:27:14 UTC
Created attachment 239149 [details]
Screenshot of the test program runing on the unaffected host
Comment 2 Bertrand Petit 2022-12-31 11:28:43 UTC
Created attachment 239150 [details]
Test program used to produce the two screenshots
Comment 3 Bertrand Petit 2022-12-31 11:29:44 UTC
Created attachment 239151 [details]
Makefile that can be used to build the test program
Comment 4 Daniel Engberg freebsd_committer freebsd_triage 2022-12-31 14:07:31 UTC
Hi,

This is probably what you're looking for?
https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/meson_options.txt#L21

Unfortunately this isn't in 2.14.0 or 2.14.1
https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/030759b74f5b3ce7fab6d17bbda6377444e82841

Best regards,
Daniel
Comment 5 Bertrand Petit 2022-12-31 15:26:21 UTC
(In reply to Daniel Engberg from comment #4)
Unfortunately the link you've given is not what I'm looking for: it is not the default setting that should be changed but the setting that must be editable at runtime. I braced myself, took a deep breath and had a deeper look at font config itself and its debugging output.

$ FC_DEBUG=4 ./xftest | grep 'lcdfilter'
Add Rule(kind:0, name: /usr/local/etc/fonts/conf.d/11-lcdfilter-default.conf) [edit]
	Edit lcdfilter Append lcddefault;
	Edit lcdfilter Assign lcdnone;
	Edit lcdfilter Assign lcddefault;
Add Rule(kind:0, name: /usr/local/etc/fonts/conf.avail/11-lcdfilter-legacy.conf) [edit]
	Edit lcdfilter Append lcdlegacy;
Add Rule(kind:0, name: /usr/local/etc/fonts/conf.avail/11-lcdfilter-light.conf) [edit]
	Edit lcdfilter Append lcdlight;
Rule Set: /usr/local/etc/fonts/conf.d/11-lcdfilter-default.conf
Substitute Edit lcdfilter Append lcddefault
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)
Substitute Edit lcdfilter Assign lcdnone
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
	lcdfilter: 0(i)(w)
Substitute Edit lcdfilter Assign lcddefault
	lcdfilter: 1(i)(w)
	lcdfilter: 1(i)(w)

The lcdfilter property is correctly set to lcdnone by my fonts,conf file but is later reset back to lcddefault by another file. From the full debug output it appears that the faulty file is /usr/local/etc/fonts/conf.d/90-classiclooks_qt5fontfix.conf which is part of the classiclooks 2.2.0 port. The weight of that file should had been set to a number strictly less than 50, another option is to not install that file at all.
Comment 6 Bertrand Petit 2022-12-31 15:29:19 UTC
Pinging the classiclooks port maintainer...
Comment 7 J.R. Oldroyd 2022-12-31 19:46:42 UTC
I am the classiclooks port maintainer.

TBH, I have no idea how any of this stuff works.  I just created the FreeBSD port files for this theme.

I don't actually pay much attention to this port, but it does appear that the port is still at the current classiclooks-2.2.0 version.  The developer tends to email me when he makes changes that justify a port update.

If you send me a diff of the specific changes you need, I will send it to the upstream developer for his comments.  If you feel a patch is warranted in the port, let me know too.
Comment 8 J.R. Oldroyd 2022-12-31 19:50:47 UTC
BTW, I looked at the two screenshots of the word "minimum".  Other than the top-left version numbers being different, what else are we supposed to see that's different?  The two "minimum" words look the same to me!
Comment 9 Bertrand Petit 2022-12-31 21:32:58 UTC
(In reply to J.R. Oldroyd from comment #7)
Configuration files in /usr/local/etc/fonts/conf.d are evaluated sequentially according to the ascending numerical order of the two digits integer prefixing the filenames stored in this directory. User's configuration files are loaded by the 50-user.conf file. Thus, the contents of any file whose number is larger that 50 forcibly overwrite settings done by the user, that is the case for 90-classiclooks_qt5fontfix.conf.

Since the settings done by that file are heavy handed I recommend to either 1) rename it to 19-classiclooks_qt5fontfix.conf (it fits into the 10 to 19 range, called "system rendering defaults"); or 2) install it into /usr/local/etc/fonts/conf.avail, again with a 19 prefix number, to inhibit its effects until the user decide to enable it by moving it to the conf.d directory. Whichever option you choose will be OK for me since the effects will be reversible for 1) or not present at all by default for 2).

As for the difference between the two images: please look closely to the curved sections of the rendered word, edges are colored, the unaffected rendering is monochrome. The colored version looks more blurry to me, especially at smaller sizes. Adding blur to an already myopic vision is not a positive effect. We all have different visual system performances, the colored version probably look better to other people I'm unfit to judge. I think we should not force one rendering method over another because of these biological differences.
Comment 10 J.R. Oldroyd 2023-01-02 21:02:11 UTC
I emailed the developer on Jan 1st and am awaiting his comments.

Renaming it to 19- looks reasonable to me.

As for whether to install it in /usr/local/etc/fonts/conf.d/ or only in conf.avail, my question is if it is needed for the other four values that are set in that file: hinting, hintstyle, antialias and rgba ?  Are these set elsewhere too, or is this file needed for them?

Thanks for the explanation of the coloring of the curves.  I still can't see this, but perhaps that is due to using a lower-quality laptop display at the moment.
Comment 11 Bertrand Petit 2023-01-04 21:42:46 UTC
(In reply to J.R. Oldroyd from comment #10)
Root defaults for all parameters are provided by the library itself. Configuration files in conf.d are intended to override those root defaults, specifically, to provide system-wide defaults (up to files numebred 49), and then to fine tune some parameters for common fonts (files numbered from 59 to 99). All of those files are optional, we can run fontconfig without any of them, no dire effect will be observed. As a summary you can read /usr/local/etc/fonts/conf.d/README, the full documentation is located in /usr/local/share/doc/fontconfig.
Comment 12 J.R. Oldroyd 2023-01-04 22:11:07 UTC
(In reply to Bertrand Petit from comment #11)

No response yet from the developer.

But in light of your explanation, I propose to install the file only as conf.avail/19-classiclooks_qt5fontfix.conf and not add the symlink in conf.d.

In a moment I shall attach a port update patch to this effect.
Comment 13 J.R. Oldroyd 2023-01-04 22:13:18 UTC
Created attachment 239265 [details]
patch to update port from 2.2.0 to 2.2.0_1

This patch changes the installed name of 90-classiclooks_qt5fontfix.conf to 19-classiclooks_qt5fontfix.conf.  It installs the file only in conf.avail and no longer adds the symlink from conf.d.
Comment 14 J.R. Oldroyd 2023-01-04 22:19:20 UTC
And, in what has to be a very odd coincidence of timing, at exactly the same time I was posting the last two messages with the 19- patch, the upstream developer did reply and he also confirmed that he is okay with this.
Comment 15 Bertrand Petit 2023-01-04 22:38:51 UTC
(In reply to J.R. Oldroyd from comment #13)
Your patch looks fine. Once committed it will permit me to install back the theme. I hope it will help me fix Inkscape's expansive use of screen real estate. Thank you.
Comment 16 J.R. Oldroyd 2023-01-04 22:43:38 UTC
The developer has just pointed out that the patch is necessary for users of Qt and that it therefore should also be linked in conf.d with the 19- name.  He says that fonts look terrible on Qt without it.

So since you already said in comment #9 that you'd be okay with that link too, I guess I'll redo that port update patch to add the link back.
Comment 17 J.R. Oldroyd 2023-01-04 23:18:57 UTC
Created attachment 239266 [details]
patch to update port from 2.2.0 to 2.2.0_1 with conf.d link

Based on feedback from the developer, here is a second port update patch that installs the file as conf.avail/19-classiclooks_qt5fontfix.conf and then also makes the symlink in conf.d.

I cannot see any difference here, myself.  I don't use a Qt desktop and the only Qt apps I have look perfectly fine with or without this qt5fontfix in conf.d.

Perhaps this is font-dependent?

Perhaps this is needed on Linux and not on FreeBSD?

Anyway, I'll leave it to you, Bertrand, and any others who can see a difference to decide which version we need.  I will remove the maintainer-approval flags for now.  Once we have a consensus, I'll remove the unneeded patch and (re-)approve the needed one.
Comment 18 J.R. Oldroyd 2023-01-05 21:40:31 UTC
The developer has now tested this on Linux.

His feedback is that it seems that the fontconfig libraries appear to have changed since he found this file to be necessary and that things look good on Gtk apps both with and without the file in conf.d, but that Qt apps still ignore the GUI's anti-alias setting.  Given that Qt apps do not honor a GUI setting, he expresses a preference to still keep the file linked in conf.d.  I would add that this would probably also still be important for when the theme is installed on a system with older libraries.

So I guess I will go ahead and approve the second version of the port update patch, the one that renames the file to 19-classiclooks_qt5fontfix.conf and also keeps the symlink in conf.d.

The developer has said that he'll continue to test on his own systems a little while longer and, all being well, he'll make an update incorporating this change.  When he does that, I will update the port again too.
Comment 19 Bertrand Petit 2023-01-05 21:51:19 UTC
(In reply to J.R. Oldroyd from comment #17)
Your second patch also looks fine. May I suggest that the obsolete flag be raised on the first one?

You may not observe the effect of the fontconfig settings because of a high screen pitch, mine is 96x96 ppi. On this screen, with classiclooks configuration in effect, dramatic text appearance changes in net/quiterss are obvious, would you like some screenshots?