Search code examples
c++linuxresourcesassetsdirectory-structure

Where do I place a font, or other resources, which my program uses?


I am writing a graphical application for linux, which requires a particular font. Currently, I have the following setup:

root-dir/
  include/
    foo.h
  src/
    foo.cpp
  fontname/
    fontlicense.txt
    font-regular.ttf
  main.cpp
  Makefile

The problem here is, although the program runs when I am currently in my development directory, it will not function if I install it to /usr/local/bin and try to run it anywhere else on the system.

In other words, how do I put fontlicense.txt and fontregular.ttf in a particular location, and expect it to be able to find it anywhere on the system?

And how would I make it override these resources with the ones in the current working directory, as well, so that I can test it in development with different resources?

(The same goes for other resources, such as graphics for the program.)


Solution

  • Linux apps should use fontconfig to locate fonts and install font files in the fontconfig default location (typically subdirectories of /usr/share/fonts)