You are not logged in.

#1 2017-02-20 19:12:59

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Taming "font overload"

My workhorse debian system suffers from "font overload". Over time I have installed a significant number of debian font packages only to find extraneous fonts or font weights clogging up my font drop-down lists.  For example, installing package fonts-linuxlibertine for Linux Biolinum and Linux Libertine also provides extraneous Capital, Keyboard, Outline, Shadow, Initials, Display, and Display Capital typefaces. The fonts-droid package provides character sets (Arabic, Armenian, Ethiopic, Georgian, Hebrew, Japanese) I rarely use; the fallback font is just fine if they appear at all.

In other cases, debian packages have dependencies on specific font packages. While necessary for some use cases, I certainly have no need of fonts-mathjax or fonts-stix.

Fortunately, fontconfig can be configured to purge these extraneous fonts without actually removing any files or packages. Unfortunately, it uses a non-intuitive xml syntax. This example of purges "Courier 10 Pitch" (package gsfonts):

limit-gsfonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <selectfont>
    <rejectfont>
      <pattern>
        <patelt name="family">
          <string>Courier 10 Pitch</string>
        </patelt>
      </pattern>
    </rejectfont>
  </selectfont>
</fontconfig>

It is also possible to specify multiple typeface families in a single file by repeating the pattern section. An example eliminating the "extraneous" typefaces for fonts-linuxlibertine:

limit-libertine.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <selectfont>
    <rejectfont>
      <pattern>
        <patelt name="family">
          <string>Linux Biolinum Capitals O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Biolinum Keyboard O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Biolinum Outline O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Biolinum Shadow O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Libertine Capitals O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Libertine Display Capitals O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Libertine Display O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Libertine Display Slanted O</string>
        </patelt>
      </pattern>
      <pattern>
        <patelt name="family">
          <string>Linux Libertine Initials O</string>
        </patelt>
      </pattern>
    </rejectfont>
  </selectfont>
</fontconfig>

Place these files in ~/.config/fontconf/conf.d to alter a single user's configuration, or /etc/fonts/conf.d to alter the system configuration. Note system files should also be prefixed with a number, like "20-", to be correctly sequenced in the configuration. Files in the user configuration need only be sequenced in complex (fontconfig expert) configurations.

Offline

#2 2017-02-21 06:59:06

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,556
Website

Re: Taming "font overload"

Many thanks for this! I'm also suffering from totally bloated-out font lists that take minutes to scroll through...


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#3 2017-02-21 16:13:04

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Taming "font overload"

@johnraff - With an excessively bloated font list, you can create multiple configurations to disable/enable working sets as needed. Sets can be disabled by simply renaming them as "dot" (hidden) files and enabled by eliminating the dot.

Offline

#4 2017-02-21 19:57:51

ohnonot
...again
Registered: 2015-09-29
Posts: 3,829
Website

Re: Taming "font overload"

i think too many installed fonts can affect system performance, since they need to be "loaded" somehow when X starts...?

do you think the described changes would affect that also, or is it rather a convenience for the user?

Offline

#5 2017-02-21 22:11:51

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Taming "font overload"

Do too many fonts affect performance? More processing always requires more time, but I don't find it significant. I regularly remove unused fonts but do not notice a performance benefit. I have removed as many as 20 fonts at once (80-120 font files: normal, italic, bold, bold-italic + double for the type1 fonts) from ~/.fonts and never thought "It starts so much faster now." In fact, I did not notice at all.

The job of the font system (fontconfig) is to enumerate the available fonts, provide equivalences, and set rules to transform the fonts . The fontconfig xml format is unwieldy, but the actual data set is not that large and the number of fonts (25 typefaces, 165 files in a typical setup) is also not large. Fontconfig monitors all configuration locations and automatically reloads after any change. Because any change can cascade to affect further configuration, it must reload the entire configuration. This is quick something along the line of two seconds for a big font collection (Core i5, 2.GHz, 45ish typefaces, 275ish files) before I can refresh the changes into my applications.

I think the slowest part of fontconfig is building the font cache. Fortunately, this need only be done once for each new font, not every instance of fontconfig. I expect the described <rejectfont> changes are merely a convenience, and may even increase the load time but along the order of a few milliseconds to parse and apply the additional rules.

Offline

#6 2017-02-22 01:23:50

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,556
Website

Re: Taming "font overload"


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#7 2017-02-24 19:01:58

ohnonot
...again
Registered: 2015-09-29
Posts: 3,829
Website

Re: Taming "font overload"

cpoakes wrote:

Do too many fonts affect performance?

it's something i remember from long ago.

i guess it makes sense, esp. when you think of that "super mega font package - download all fonts ever" thrown together by some over-enthusiastic freeware fan... preferably with a few broken fonts strewn in...

but of course it depends on the hardware.

still, i wonder if a large number of "installed" fonts would mean a constant performance penalty, or only during startup.
i think fontconfig, xft and the like are very deeply involved in all GUI things happening on linux.

Offline

#8 2017-02-28 01:55:14

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Taming "font overload"

@ohnonot - It's kinda something I remember from long ago too, like boot times that were measured in minutes. Please don't take my anecdotal evidence as gospel; I simply find I don't notice the difference. And I do minimize the font load on older/less powerful hardware - not because I notice any difference there either, I simply minimize and optimize everything assuming the milliseconds add up.

If you want lots-o-fonts on your machine but want to treat them as load-on-demand, put each set in its own directory (like ~/.fonts/Broadway or ~/.fonts/Georgia). Then create a hidden directory in ~/.fonts (like ~/.fonts/.obscured). Since fontconfig ignores hidden files/directories, simply move your fonts in or out of the obscured folder to omit or employ them as needed.

For example, I currently have 75 font folders in .text, .display, .mono, and .decorative, both hiding and categorizing them for future reference.

Offline

Board footer

Powered by FluxBB