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

Helmut Tessarek ml at evermeet.cx
Mon Aug 27 17:48:28 PDT 2012


On 27.08.12 19:26 , Raimund Steger wrote:
> Should work:
>
> /* ...
>  * no FcInit*() before this point */
> char cfgpath[PATH_MAX];
> /* need to add "." if relative paths are involved: */
> snprintf(cfgpath,PATH_MAX,"%s/cfg:.",dirname(argv[0]));
> setenv("FONTCONFIG_PATH",cfgpath,1);
> FcInit();
>
> Then, if ./cfg is a valid configuration:
>
> FC_DEBUG=1024 ./the-binary
>
> shows:
>
>         Loading config file ./cfg/fonts.conf
>         Scanning config dir ./cfg/conf.d
>         Loading config file ././cfg/conf.d/20-fix-globaladvance.conf
>         [...]

The problem is that it does not work. I tried in ffmpeg.c, as well as in
libavfilter/vf_drawtext.c and it is just not working.

There is apparently no way to get ffmpeg to use ./cfg/ as the config path for
fontconfig.
The only way seems to be to set the env variable _before_ starting ffmpeg.
If you set it in ffmpeg, it is ignored.

Very weird, since it does not make any sense.

IMO it is logical to use a relative config dir, when working with static
binaries...

Anyway, I guess I have to patch fontconfig and use the patched fontconfig
library. This seems to be the only solution for this problem.

Helmut



More information about the Fontconfig mailing list