FontConfig
From OFLB
FontMatrix is a great free software tool for managing fonts! This information is left here for historic/informational purposes.
April 2007 Author: Bats
Contents |
Overview
I have been trying to 'grok' fontconfig, the system that modern Gnu/Linux systems use to herd fonts about the place. I am not an expert, simply a bloke who wants one thing: Virtually no arbitrary fonts in my font choosers.
When I say 'virtually' it means I recognize that there will be a few sundry fonts that one cannot get away from. It also means that over 100+ fonts in a chooser is just bonkers.
Why all this fuss? Well, my O/S at the moment (2007) is Kubuntu Dapper-Drake Gnu/Linux and (largely through my own fault) I have over 600 fonts installed on the system. I have found that they all show up in my choosers under apps like Inkscape and The Gimp and so on. You try scroll through that and stay sane!
So, I started searching and found references to this fontconfig thing and one thing led to another and I finally found some time to poke it with a stick -- since my questions on the mailing lists where being met with silence -- I had to.
Conclusions
Let's start with the end. These are my own interpretations of the situation and are all wrong (or right) on that basis. I'll edit this page as I learn new stuff.
What fontconfig is
- fontconfig is a system that supplies fonts to applications. It says, "Here is the list of all the fonts I know about."
- It's up to the applications (or their gui toolkits) to deal with that.
- It's up to the applications (or their gui toolkits) to actually draw fonts.
- Most applications treat fonts with less than the required respect. If they did not, Gnu/Linux could have tools as sophisticated as those of Apple's.
- The problem is that the basic font choosers built into the two big desktops (KDE and GNOME) are rubbish and they do not make full use of fontconfig, nor do they attempt anything approaching font management -- allowing users to group fonts at will and hide/show them in their choosers. (KDE 4 is making strides and a manager seems to be in development.)
The overall conclusion is this:
For the foreseeable future, the more fonts that are on your system, the more fonts
you will have to wade through in your choosers. H.A.N.D.
How we can lessen font-clutter
- Don't install more fonts system-wide than you need. Easy to say but also easy to do.
- Manage your fonts with something like Fonty Python () which uses your private user font folder (~/.fonts).
- Remove the individual fonts that you do not want to have available. At the moment this is a manual process that I describe in more detail in the sections to follow.
The way to remove individual fonts is to find their path and then move them
to a neutral directory (one that fontconfig is not watching).
Notes
-
Text like this is console input or output, unless it's obviously not.
- Commands will start with a $ sign. Do not type it.
Basic fontconfig commands
fc-list
In order to list all the fonts installed on the system, or with varying degrees of information, use the fc-list command. The parameters tell it what stuff to tell you about. For example to list all the fonts by family name:
$fc-list : family
The colon is "an empty pattern that matches all fonts". Just include it for fc-list to work.
That shows:
World of Water Electorate Blue Kirsty Junkyard wasy10 ...
To list all by family and style:
$fc-list : family style
That shows:
Holy Smokes:style=Regular Living by Numbers:style=Regular Verdana:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta Dustismo:style=Regular Luxi Serif:style=RegularM ...
Looking for specific fonts. Let's find the 'URW Bookman' range:
$fc-list : file family style | grep -i bookman | sort
Here we ask fontconfig for the filename, the family and the style and then pipe it all to grep where we then look for lines with 'urw' in them, then we pipe it to sort to keep it neat. The result? On my system:
/usr/share/X11/fonts/Type1/b018012l.pfb: URW Bookman L:style=Light /usr/share/X11/fonts/Type1/b018015l.pfb: URW Bookman L:style=Demi Bold /usr/share/X11/fonts/Type1/b018032l.pfb: URW Bookman L:style=Light Italic /usr/share/X11/fonts/Type1/b018035l.pfb: URW Bookman L:style=Demi Bold Italic /usr/share/fonts/type1/gsfonts/b018012l.pfb: URW Bookman L:style=Light /usr/share/fonts/type1/gsfonts/b018015l.pfb: URW Bookman L:style=Demi Bold /usr/share/fonts/type1/gsfonts/b018032l.pfb: URW Bookman L:style=Light Italic /usr/share/fonts/type1/gsfonts/b018035l.pfb: URW Bookman L:style=Demi Bold Italic
fc-cache
This one I am less clear on. It builds a file called fonts.cache-1 in the current directory. It may do more. If you run it in a directory that contains subdirectories, it will list those subdirectories in the fonts.cache-1 file. If you run it in a directory full of font files, the fonts.cache-1 file is full of technical (and kinda garbled) info about each font file.
These cache files are used by fontconfig when it needs to know where things are. When you query it from fc-list, it's using these files to find stuff.
When you make a change in a directory that you want to reflect in fontconfig, then you must remove the old cache and make a new one. This must be done as root, here I use the Ubuntu sudo approach:
$sudo rm fonts.cache-1 $sudo fc-cache
Some Debian/Ubuntu package command - in terms of fonts
If you wanted to find what package a certain font came in, you can follow this recipe: Find the filename of the font with fc-list. Let's pick on "Canadian Participants" - an odd font that appears in my Inkscape chooser.
$fc-list : file family | grep -i canadian
Which gives:
/usr/share/fonts/truetype/larabie-uncommon/canap___.ttf: Canadian Participants
So, we know the path.
Then use that path (select the filename it with the cursor) and paste it where appropriate:
dpkg-query -S canap___.ttf
The search can take a while, but here is the result:
ttf-larabie-uncommon: /usr/X11R6/lib/X11/fonts/TrueType/larabie-uncommon/canap___.ttf ttf-larabie-uncommon: /usr/share/fonts/truetype/larabie-uncommon/canap___.ttf
So, you can see the package name is "ttf-larabie-uncommon". If you wanted to remove it, you can use apt-get and company.
How to remove a single font from a system-wide installation
To do. Emergency web-job came in, all stop for now. :(