]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/fontmgr.cpp
Fix compilo due to r47267.
[wxWidgets.git] / src / dfb / fontmgr.cpp
index 76b09cf1b381d4e35c08c6156d8177f6446775a3..7abfabaacfd1e97d01c15b9c3ba2ca3dce1fb6ff 100644 (file)
     #pragma hdrstop
 #endif
 
+#ifndef WX_PRECOMP
+    #include "wx/utils.h"
+    #include "wx/log.h"
+#endif
+
 #include "wx/fileconf.h"
 #include "wx/filename.h"
 #include "wx/tokenzr.h"
 // wxFontInstance
 // ----------------------------------------------------------------------------
 
+// This is a fake "filename" for DirectFB's builtin font (which isn't loaded
+// from a file); we can't use empty string, because that's already used for
+// "this face is not available" by wxFontsManagerBase
+#define BUILTIN_DFB_FONT_FILENAME   "/dev/null"
+
 wxFontInstance::wxFontInstance(float ptSize, bool aa,
                                const wxString& filename)
     : wxFontInstanceBase(ptSize, aa)
@@ -50,7 +60,11 @@ wxFontInstance::wxFontInstance(float ptSize, bool aa,
                     DFDESC_ATTRIBUTES | DFDESC_FRACT_HEIGHT);
     desc.attributes = aa ? DFFA_NONE : DFFA_MONOCHROME;
     desc.fract_height = pixSize;
-    m_font = wxIDirectFB::Get()->CreateFont(filename.fn_str(), &desc);
+
+    if ( filename == BUILTIN_DFB_FONT_FILENAME )
+        m_font = wxIDirectFB::Get()->CreateFont(NULL, &desc);
+    else
+        m_font = wxIDirectFB::Get()->CreateFont(filename.fn_str(), &desc);
 
     wxASSERT_MSG( m_font, _T("cannot create font instance") );
 }
@@ -139,6 +153,12 @@ void wxFontsManager::AddAllFonts()
     {
         wxString dir = tkn.GetNextToken();
 
+        if ( !wxDir::Exists(dir) )
+        {
+            wxLogDebug(_T("font directory %s doesn't exist"), dir);
+            continue;
+        }
+
         wxArrayString indexFiles;
         if ( !wxDir::GetAllFiles(dir, &indexFiles, _T("FontsIndex")) )
             continue;
@@ -152,8 +172,23 @@ void wxFontsManager::AddAllFonts()
 
     if ( GetBundles().empty() )
     {
-        // wxDFB is unusable without fonts, so terminate the app
-        wxLogFatalError(_("No fonts found in %s."), path.c_str());
+        // We can fall back to the builtin default font if no other fonts are
+        // defined:
+        wxLogTrace(_T("font"),
+                   _("no fonts found in %s, using builtin font"), path);
+
+        AddBundle
+        (
+          new wxFontBundle
+              (
+                _("Default font"),
+                BUILTIN_DFB_FONT_FILENAME,
+                wxEmptyString,
+                wxEmptyString,
+                wxEmptyString,
+                false // IsFixed
+              )
+        );
     }
 }