summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Font.cc20
-rw-r--r--src/Font.hh4
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 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Font.cc,v 1.12 2002/10/14 18:25:37 fluxgen Exp $ 22//$Id: Font.cc,v 1.13 2002/10/15 10:56:49 fluxgen Exp $
23 23
24 24
25#include "Font.hh" 25#include "Font.hh"
@@ -65,7 +65,9 @@ namespace FbTk {
65bool Font::m_multibyte = false; 65bool Font::m_multibyte = false;
66bool Font::m_utf8mode = false; 66bool Font::m_utf8mode = false;
67 67
68Font::Font(const char *name, bool antialias) { 68Font::Font(const char *name, bool antialias):
69m_fontimp(0),
70m_antialias(false) {
69 71
70 // MB_CUR_MAX returns the size of a char in the current locale 72 // MB_CUR_MAX returns the size of a char in the current locale
71 if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte 73 if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte
@@ -81,10 +83,11 @@ Font::Font(const char *name, bool antialias) {
81 } 83 }
82 84
83 // create the right font implementation 85 // create the right font implementation
86 // antialias is prio 1
84#ifdef USE_XFT 87#ifdef USE_XFT
85 antialias = true;
86 if (antialias) { 88 if (antialias) {
87 m_fontimp = std::auto_ptr<FontImp>(new XftFontImp()); 89 m_fontimp = std::auto_ptr<FontImp>(new XftFontImp());
90 m_antialias = true;
88 } 91 }
89#endif //USE_XFT 92#endif //USE_XFT
90 // if we didn't create a Xft font then create basic font 93 // if we didn't create a Xft font then create basic font
@@ -108,18 +111,19 @@ Font::~Font() {
108void Font::setAntialias(bool flag) { 111void Font::setAntialias(bool flag) {
109 112
110#ifdef USE_XFT 113#ifdef USE_XFT
111 bool is_antialias = typeid(m_fontimp) == typeid(XftFontImp); 114 if (flag && !isAntialias()) {
112
113 if (flag && !is_antialias) {
114 m_fontimp = std::auto_ptr<FontImp>(new XftFontImp(m_fontstr.c_str())); 115 m_fontimp = std::auto_ptr<FontImp>(new XftFontImp(m_fontstr.c_str()));
115 } else if (!flag && is_antialias) 116 } else if (!flag && isAntialias())
116#endif // USE_XFT 117#endif // USE_XFT
117 { 118 {
118 if (m_multibyte || m_utf8mode) 119 if (m_multibyte || m_utf8mode)
119 m_fontimp = std::auto_ptr<FontImp>(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); 120 m_fontimp = std::auto_ptr<FontImp>(new XmbFontImp(m_fontstr.c_str(), m_utf8mode));
120 else 121 else {
121 m_fontimp = std::auto_ptr<FontImp>(new XFontImp(m_fontstr.c_str())); 122 m_fontimp = std::auto_ptr<FontImp>(new XFontImp(m_fontstr.c_str()));
123 }
122 } 124 }
125
126 m_antialias = flag;
123} 127}
124 128
125bool Font::load(const char *name) { 129bool 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 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Font.hh,v 1.5 2002/10/13 22:24:14 fluxgen Exp $ 22//$Id: Font.hh,v 1.6 2002/10/15 10:55:30 fluxgen Exp $
23 23
24#ifndef FBTK_FONT_HH 24#ifndef FBTK_FONT_HH
25#define FBTK_FONT_HH 25#define FBTK_FONT_HH
@@ -61,12 +61,14 @@ public:
61 unsigned int textWidth(const char *text, unsigned int size) const; 61 unsigned int textWidth(const char *text, unsigned int size) const;
62 unsigned int height() const; 62 unsigned int height() const;
63 void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; 63 void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
64 bool isAntialias() const { return m_antialias; }
64private: 65private:
65 66
66 std::auto_ptr<FontImp> m_fontimp; 67 std::auto_ptr<FontImp> m_fontimp;
67 std::string m_fontstr; 68 std::string m_fontstr;
68 static bool m_multibyte; 69 static bool m_multibyte;
69 static bool m_utf8mode; 70 static bool m_utf8mode;
71 bool m_antialias;
70}; 72};
71 73
72}; //end namespace FbTk 74}; //end namespace FbTk