I’m working on an application primary targeted for Linux, which use a TTF font. I need the font’s file name and path, because I have to load it with SDL function TTF_OpenFont(char *file, …). The problem is that there are a lot of different directories for TTF fonts on different distribution. Which is the best way to deal with this problem? I’ve came up some solutution, but each of them seems suboptimal for me:
- pack the font along with the application, and install it to the application’s own /usr/share/ directory.
- check the font path with
fc-list : file. - hardcode every path variation to the application and try them out when load the file.
Your first and second solutions are quite good, except it may be better to call FcFontList function. Third one is quite unreliable, but it highly depends on application type (it can be ok in some cases, if you have this path configurable by user).