[Fontconfig] how to read config file from current dir (relative to a binary using the lib)

Raimund Steger rs at mytum.de
Mon Aug 27 16:26:06 PDT 2012

Helmut Tessarek wrote:
> [...]
> Anyway, I understand that using the ENV var is the only way to manipulate the
> config path. But here's the next problem.
> a) fontconfig linked statically
> b) some binary using fontconfig also linked statically
> I use setenv in b) to set the FONTCONFIG_PATH variable, but a) ignores it.

Should work:

/* ...
  * no FcInit*() before this point */
char cfgpath[PATH_MAX];
/* need to add "." if relative paths are involved: */

Then, if ./cfg is a valid configuration:

FC_DEBUG=1024 ./the-binary


         Loading config file ./cfg/fonts.conf
         Scanning config dir ./cfg/conf.d
         Loading config file ././cfg/conf.d/20-fix-globaladvance.conf

Note that binaries on Windows have different defaults than UNIX.


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

More information about the Fontconfig mailing list