[Fontconfig] How to prevent Chromium from scaling bitmapped fonts?

Raimund Steger rs at mytum.de
Wed Mar 16 23:34:56 UTC 2016


On Wed, 16 Mar 2016 12:37:00 -0400
Kynn Jones <kynnjo at gmail.com> wrote:
> In order to prevent this rule from being affected by any additional
> rules I put in the file, I tried adding to it the `<test>` clause
> shown below, so that the rules applies only when `prgname` is *not*
> `chromium`; unfortunately, this causes the rule to stop working (e.g.
> on Iceweasel):

This negative check should not be needed. Your "default" rule won't hurt if it's evaluated for Chromium too. (target=pattern rules are evaluated top to bottom for every font query made by the application.) I think all you need to do is assign TrueType format in this specific case on top of what you already do.

In my test (with nothing else in fonts.conf and both PCF & TTF Terminus installed), a simple rule like the following worked:

  <match target="pattern">
    <test name="prgname"><string>chrome</string></test>
    <edit name="family"><string>Terminus</string></edit>
    <edit name="scalable" mode="assign"><bool>false</bool></edit>
    <edit name="fontformat" mode="assign"><string>TrueType</string></edit>
  </match>

In your case, even the following, located below your "default" rule, should work:

  <match target="pattern">
    <test name="prgname"><string>chrome</string></test>
    <edit name="fontformat" mode="assign"><string>TrueType</string></edit>
  </match>

(I tested it with the "chrome" executable. "chromium" is correct if it's called that in your distribution.)
NB. The behavior you describe sounds a bit like "prgname" wasn't set at all in your build (because not_eq is false then as well unless qual=all). But in your earlier mail I saw it in the debug output, so that's not likely.

> BTW, in general, is there a better way to test the syntactic
> correctness of a `fonts.conf` file than by observing the effects it
> may have on running applications?

Well the syntactic correctness is tested by fontconfig's parser! But in terms of what properties are supported, this is dynamic (you can assign your own, for instance) so that's difficult to check. It's usually necessary to run isolated tests with FC_DEBUG=1|3|4 to work one's way through a misbehaving config.

> Lastly, do you know of a good source of examples that illustrate the
> fontconfig syntax?  I've read the documentation multiple times, but I
> still hardly understand at all how to configure stuff through
> `fonts.conf`.

Most of it can be deduced from fonts-conf(5) and the DTD which is normally installed in $PREFIX/share/xml/fontconfig/fonts.dtd. Although some explanations are rather short there. A "friendlier" documentation doesn't exist in one place I think.

> PS: FWIW, I've reported the problem with Chromium, here
> 
> https://bugs.chromium.org/p/chromium/issues/detail?id=593041
> 
> unfortunately, the issue has received scant attention.

I have the impression that Chromium was designed from the ground up to support only scalable fonts. That explains why they select the font file at a time when the size isn't known. (Some scalable fonts have design sizes too, but well...) Generally, in my tests I found that even if it's tricked to use a bitmap font everywhere, it will *still* expect that it can be scaled to say 15px when there is only 14, or 16px. This results in badly scaled glyphs with missing pixels or such. I've just observed it with Terminus in the settings dialog. I don't know how necessary Chromium is for your desktop; in the end it might be less frustrating to focus on Firefox/Iceweasel.

Raimund


-- 
Worringer Str 31 Duesseldorf 40211 DE  home: rs at mytum.de
+49-179-2981632 icq 16845346           work: rs at interface-ag.de


More information about the Fontconfig mailing list