[Fontconfig] how to correctly set fontconfig on Windows

Tor Lillqvist tml at iki.fi
Thu Oct 18 01:29:34 PDT 2007

> I have installed the true type fonts in:
> c:\Program Files\CommonFiles\Efl\share\fonts
> (Efl is the name of the package).

Any particular reason why you don't install them into Windows itself?
Are they strictly for use by Efl only from licensing or usefulness
point of view, and are there so many of them that having them visible
in the normal font selection of Windows apps would just cause lots of

Presumably the Efl code really *does* require fontconfig, either by
using it directly or by using the pangoft2 library?

> Of course, if I just do that,

You didn't tell where you installed fontconfig, and whether you used a
prebuilt package like mine at
or from somewhere else, or whether you compiled fontconfig yourself?

> fontconfig can not find the fonts and I get
> the error:
> Fontconfig error: Cannot load default config file

Well, that message doesn't say that it can't find the fonts, it says
that it can't find the fonts.conf file. (But the end result of course
is that no fonts are found either, as it is the fonts.conf file which
tells where to look for fonts...)

> What I would like to know is how I can correctly set fontconfig on
> Windows.

I would unzip the above zip file (or a newer version if/when one is
available) into the c:\Program Files\CommonFiles\Efl folder, and not
move the files thus unzipped around after that. Then in c:\Program
Files\CommonFiles\Efl\etc\fonts\fonts.conf I would replace
"<dir>~/.fonts</dir>" with "<dir>c:/program files/common
files/efl/share/fonts</dir>. (Hmm, I hope it works to have spaces in

> I know that if I install gtk runtime (for gimp) or Xchat2 on
> Windows (well, xchat uses gtk but install fontconfig in its own
> directory), fontconfig can detect the font files.

With "the" font files, do you mean the ones installed in the Windows
font folder, or the ones you installed into Efl\share\fonts ?

(Anyway, I wonder why Xchat2 comes bundled with fontconfig, does it
really need it? GIMP does, but not GTK+ applications in general.)

> I know that I can use the environment variables

Sorry, I have never played with those, can't say anything about them.

> Can someone tell what I have to do during the installation of that library
> to set up correctly fontconfig ?

fontconfig as a concept is rather foreign to Windows, so using it on
Windows is not really "correct" (in a more philosophical sense)... One
should use fontconfig on Windows only if the code absolutely requires
fontconfig. At least, that's what Owen always says unless I'm
mistaken. But anyway, hopefully the above should give you some help.

The key point is that the location of the default fonts.conf file is
constructed from the location of the fontconfig DLL. The DLlMain()
function in the DLL asks the system where it is located.

The DLL should be in "someprefix\bin" (or "someprefix\lib", although
that is not really recommended), and the fonts.conf file then in
"someprefix\etc\fonts". If the DLL is in a folder whose last component
isn't "bin" or "lib", then the fonts.conf file should be in
"etc\fonts" directly under that folder.

This is the same logic that GTK+ and all other related stuff I have
ported to Windows use to find its installation location at run time.
As far as I know it works fine, although in fontconfig's case the code
only uses the ANSI variants of the APIs so it won't work if pathnames
with characters not in the system codepage are involved.


More information about the Fontconfig mailing list