Fonts collector now seems to work on Linux, and presumably on other posix systems.

Originally committed to SVN as r1462.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-30 00:56:54 +00:00
parent 0ccf9cb111
commit 1e1f7b411b

View file

@ -49,7 +49,8 @@ wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
// Code stolen from asa // Code stolen from asa
FcPattern *final, *tmp1, *tmp2; FcPattern *final, *tmp1, *tmp2;
FcResult res; FcResult res;
FcChar8 *filename; FcChar8 *filename,*gotfamily;
int fontindex;
char buffer[1024]; char buffer[1024];
strcpy(buffer,facename.mb_str(wxConvUTF8)); strcpy(buffer,facename.mb_str(wxConvUTF8));
@ -58,11 +59,16 @@ wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
if (!tmp1) return results; if (!tmp1) return results;
tmp2 = FcFontRenderPrepare(fontconf, tmp1, aux); tmp2 = FcFontRenderPrepare(fontconf, tmp1, aux);
FcPatternDestroy(tmp1); FcPatternDestroy(tmp1);
FcDefaultSubstitute(tmp2);
FcConfigSubstitute(fontconf, tmp2, FcMatchPattern);
final = FcFontMatch(fontconf, tmp2, &res); final = FcFontMatch(fontconf, tmp2, &res);
FcPatternDestroy(tmp2); FcPatternDestroy(tmp2);
if (!final) return results; if (!final) return results;
if (FcPatternGetString(final, FC_FILE, 0, &filename) == FcResultMatch) { if (FcPatternGetString(final, FC_FILE, 0, &filename) == FcResultMatch && FcPatternGetInteger(final, FC_INDEX, 0, &fontindex) == FcResultMatch) {
results.Add(wxString((char*) filename,wxConvLocal)); FcPatternGetString(final, FC_FAMILY, fontindex, &gotfamily);
if (strcmp(gotfamily,buffer) == 0) {
results.Add(wxString((char*) filename,wxConvLocal));
}
} }
FcPatternDestroy(final); FcPatternDestroy(final);