From c4f6f41c841cfea28c69b4194d0d44e4cf040cf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 15 May 2007 12:38:19 +0000 Subject: [PATCH] fall back to DirectFB's builtin font if no fonts are configured git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/dfb/fontmgr.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/dfb/fontmgr.cpp b/src/dfb/fontmgr.cpp index fc97601..7abfaba 100644 --- a/src/dfb/fontmgr.cpp +++ b/src/dfb/fontmgr.cpp @@ -37,6 +37,11 @@ // 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) @@ -55,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") ); } @@ -163,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 + ) + ); } } -- 2.7.4