From 4acb333856c159ffcf1b252930e944ca6b8083bb Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 15 Oct 2002 10:56:49 +0000 Subject: antialias check --- src/Font.cc | 20 ++++++++++++-------- src/Font.hh | 4 +++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Font.cc b/src/Font.cc index ddc78e3..cb169ac 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.12 2002/10/14 18:25:37 fluxgen Exp $ +//$Id: Font.cc,v 1.13 2002/10/15 10:56:49 fluxgen Exp $ #include "Font.hh" @@ -65,7 +65,9 @@ namespace FbTk { bool Font::m_multibyte = false; bool Font::m_utf8mode = false; -Font::Font(const char *name, bool antialias) { +Font::Font(const char *name, bool antialias): +m_fontimp(0), +m_antialias(false) { // MB_CUR_MAX returns the size of a char in the current locale if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte @@ -81,10 +83,11 @@ Font::Font(const char *name, bool antialias) { } // create the right font implementation + // antialias is prio 1 #ifdef USE_XFT - antialias = true; if (antialias) { m_fontimp = std::auto_ptr(new XftFontImp()); + m_antialias = true; } #endif //USE_XFT // if we didn't create a Xft font then create basic font @@ -108,18 +111,19 @@ Font::~Font() { void Font::setAntialias(bool flag) { #ifdef USE_XFT - bool is_antialias = typeid(m_fontimp) == typeid(XftFontImp); - - if (flag && !is_antialias) { + if (flag && !isAntialias()) { m_fontimp = std::auto_ptr(new XftFontImp(m_fontstr.c_str())); - } else if (!flag && is_antialias) + } else if (!flag && isAntialias()) #endif // USE_XFT { if (m_multibyte || m_utf8mode) m_fontimp = std::auto_ptr(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); - else + else { m_fontimp = std::auto_ptr(new XFontImp(m_fontstr.c_str())); + } } + + m_antialias = flag; } bool Font::load(const char *name) { diff --git a/src/Font.hh b/src/Font.hh index 0fa1b0e..9de7e7a 100644 --- a/src/Font.hh +++ b/src/Font.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.hh,v 1.5 2002/10/13 22:24:14 fluxgen Exp $ +//$Id: Font.hh,v 1.6 2002/10/15 10:55:30 fluxgen Exp $ #ifndef FBTK_FONT_HH #define FBTK_FONT_HH @@ -61,12 +61,14 @@ public: unsigned int textWidth(const char *text, unsigned int size) const; unsigned int height() const; void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + bool isAntialias() const { return m_antialias; } private: std::auto_ptr m_fontimp; std::string m_fontstr; static bool m_multibyte; static bool m_utf8mode; + bool m_antialias; }; }; //end namespace FbTk -- cgit v0.11.2