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
FcPattern *final, *tmp1, *tmp2;
FcResult res;
FcChar8 *filename;
FcChar8 *filename,*gotfamily;
int fontindex;
char buffer[1024];
strcpy(buffer,facename.mb_str(wxConvUTF8));
@ -58,12 +59,17 @@ wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
if (!tmp1) return results;
tmp2 = FcFontRenderPrepare(fontconf, tmp1, aux);
FcPatternDestroy(tmp1);
FcDefaultSubstitute(tmp2);
FcConfigSubstitute(fontconf, tmp2, FcMatchPattern);
final = FcFontMatch(fontconf, tmp2, &res);
FcPatternDestroy(tmp2);
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) {
FcPatternGetString(final, FC_FAMILY, fontindex, &gotfamily);
if (strcmp(gotfamily,buffer) == 0) {
results.Add(wxString((char*) filename,wxConvLocal));
}
}
FcPatternDestroy(final);
return results;