added "iv.dynstring"
[iv.d.git] / fontconfig_samples / fclist.d
blob7877783c806c90e4056876be4a2ebb70be1953e7
1 import iv.cmdcon;
2 import iv.fontconfig;
5 void main () {
6 if (!FcInit()) assert(0, "cannot init fontconfig");
7 //scope(exit) FcFini(); // that segfaults, lol. packard, please, kill yourself.
9 FcConfig* config = FcInitLoadConfigAndFonts();
10 FcPattern* pat = FcPatternCreate();
11 FcObjectSet* os = FcObjectSetBuild(FC_FAMILY.ptr, FC_STYLE.ptr, FC_LANG.ptr, FC_FILE.ptr, null);
12 FcFontSet* fs = FcFontList(config, pat, os);
13 if (fs !is null) {
14 conwriteln("Total matching fonts: ", fs.nfont);
15 foreach (int i; 0..fs.nfont) {
16 FcPattern* font = fs.fonts[i];
17 char* file, style, family;
18 if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch &&
19 FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch &&
20 FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch)
22 conwriteln("family: <", family, ">; style: ", style, "); file: ", file);
25 FcFontSetDestroy(fs);