D. Fang
D. Fang

Reputation: 21

Fontconfig: cannot find application font

I imitated the code in this link, except that I wanted to add support for local fonts, so the code was adapted like this.

FcConfig* config = FcInitLoadConfigAndFonts();
FcConfigAppFontAddDir(config, (FcChar8*) "../fonts");
FcConfigSubstitute(config, pat, FcMatchPattern);
FcDefaultSubstitute(pat);

FcStrList* dirs = FcConfigGetFontDirs(config);
FcChar8* current;
while ((current = FcStrListNext(dirs)) != NULL)
    printf("%s\n", (char*) current);

FcResult res;
FcPattern* font = FcFontMatch(config, pat, &res);
if (font)
{
   FcChar8* file = NULL;
   if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch)
   {
      printf("%s\n", (char*) file);
   }
   FcPatternDestroy(font);
}

FcPatternDestroy(pat);
FcStrListDone(dirs);

However, I found the following situation:


Update: The fonts can only be referenced through font name as opposed to file name. Case closed.

Upvotes: -1

Views: 96

Answers (1)

D. Fang
D. Fang

Reputation: 21

Update: The fonts can only be referenced through font name as opposed to file name. Case closed.

Upvotes: 2

Related Questions