- wxString dir = _T(wxINSTALL_PREFIX "/share/wx/fonts");
- wxGetEnv(_T("WXDFB_FONTDIR"), &dir);
+ wxString path;
+ if ( !wxGetEnv("WXDFB_FONTPATH", &path) )
+ path = _T(wxINSTALL_PREFIX "/share/wx/fonts");
+
+ wxStringTokenizer tkn(path, wxPATH_SEP);
+ while ( tkn.HasMoreTokens() )
+ {
+ wxString dir = tkn.GetNextToken();
+
+ if ( !wxDir::Exists(dir) )
+ {
+ wxLogDebug("font directory %s doesn't exist", dir);
+ continue;
+ }
+
+ wxArrayString indexFiles;
+ if ( !wxDir::GetAllFiles(dir, &indexFiles, "FontsIndex") )
+ continue;
+
+ for ( wxArrayString::const_iterator i = indexFiles.begin();
+ i != indexFiles.end(); ++i )
+ {
+ AddFontsFromDir(*i);
+ }
+ }
+
+ if ( GetBundles().empty() )
+ {
+ // We can fall back to the builtin default font if no other fonts are
+ // defined:
+ wxLogTrace("font",
+ _("no fonts found in %s, using builtin font"), path);
+
+ AddBundle
+ (
+ new wxFontBundle
+ (
+ _("Default font"),
+ BUILTIN_DFB_FONT_FILENAME,
+ wxEmptyString,
+ wxEmptyString,
+ wxEmptyString,
+ false // IsFixed
+ )
+ );
+ }
+}