From 04d58f1c2db4a192cd034f11876afab3267a0eb1 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 15 Oct 2002 16:34:14 +0000 Subject: fallback on fixed if the font before was loaded but the new one couldnt load it --- src/Font.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Font.cc b/src/Font.cc index cb169ac..4d03345 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.cc,v 1.13 2002/10/15 10:56:49 fluxgen Exp $ +//$Id: Font.cc,v 1.14 2002/10/15 16:34:14 fluxgen Exp $ #include "Font.hh" @@ -38,6 +38,8 @@ #include "XFontImp.hh" #include "XmbFontImp.hh" +#include "StringUtil.hh" + //use gnu extensions #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -47,18 +49,16 @@ #define __USE_GNU #endif //__USE_GNU -#include #include -#include -#include -#include -#include +#include +#include +using namespace std; #ifdef HAVE_SETLOCALE #include #endif //HAVE_SETLOCALE -#include "StringUtil.hh" + namespace FbTk { @@ -109,7 +109,7 @@ Font::~Font() { } void Font::setAntialias(bool flag) { - + bool loaded = m_fontimp->loaded(); #ifdef USE_XFT if (flag && !isAntialias()) { m_fontimp = std::auto_ptr(new XftFontImp(m_fontstr.c_str())); @@ -123,6 +123,11 @@ void Font::setAntialias(bool flag) { } } + if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' + if (!m_fontimp->load("fixed")) // if that failes too, output warning + cerr<<"Warning: can't load fallback font 'fixed'."<