Fontforge finds no fonts
Posted
by
user1858080
on Stack Overflow
See other posts from Stack Overflow
or by user1858080
Published on 2012-11-27T23:02:26Z
Indexed on
2012/11/27
23:03 UTC
Read the original article
Hit count: 234
I'm trying to make my c++ program detect installed fonts on my Win32 machine. I tried fontforge by taking the library from the GTK+ bundle.
I use the following test code:
#include<fontconfig.h>
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);
LOG("Total fonts: %d\n", fs->nfont);
for (int i=0; fs && i < fs->nfont; i++) {
FcPattern *font = fs->fonts[i];
s = FcNameUnparse(font);
LOG("Font: %s\n", s);
free(s);
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
LOG("Filename: %s\n", file);
}
}
// destroy objects here ...
Unfortunately this test application only prints: "Total fonts: 0"
I know there are fonts installed on my machine and I know that Gimp2.0 detects them, so there must be somthing wrong with my test code. Does anyone have any idea?
Besides linking the fontconfig-1.dll I did nothing special. I haven't created any config files or anything, because I couldn't read anywhere about having to do that.
Please place any suggestions, thanks!
© Stack Overflow or respective owner