blob: a6a6411740523e8981a617d2690921fb3b1315e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <fontconfig.h>
#include <cstddef>
#include <stdio.h>
#include <stdlib.h>
int main() {
FcBool success = FcInit ();
if ( !success ) {
return false;
}
FcConfig *config = FcInitLoadConfigAndFonts ();
if(!config) {
return false;
}
FcChar8 *s, *file;
FcPattern *p = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY,NULL);
FcFontSet *fs = FcFontList(config, p, os);
printf("Total fonts: %d\n", fs->nfont);
for (int i=0; fs && i < fs->nfont; i++) {
FcPattern *font = fs->fonts[i];
s = FcNameUnparse(font);
printf("Font: %s\n", s);
free(s);
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
printf("Filename: %s\n", file);
}
}
}
|