aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2002-12-01 13:42:15 (GMT)
committerrathnor <rathnor>2002-12-01 13:42:15 (GMT)
commit28b5c604490094e187494dcc566bd3d7a05a2c25 (patch)
tree8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/FbTk/Font.cc
parentb9134162f9633784d9097df18769a699a62650fe (diff)
downloadfluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip
fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r--src/FbTk/Font.cc136
1 files changed, 68 insertions, 68 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index 949890e..c5a8366 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/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.1 2002/11/26 16:01:27 fluxgen Exp $ 22//$Id: Font.cc,v 1.2 2002/12/01 13:42:14 rathnor Exp $
23 23
24 24
25#include "Font.hh" 25#include "Font.hh"
@@ -66,43 +66,43 @@ bool 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), 69 m_fontimp(0),
70m_antialias(false), m_rotated(false) { 70 m_antialias(false), m_rotated(false) {
71 71
72 // 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
73 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
74 m_multibyte = true; 74 m_multibyte = true;
75 75
76 char *s; // temporary string for enviroment variable 76 char *s; // temporary string for enviroment variable
77 // check for utf-8 mode 77 // check for utf-8 mode
78 if (((s = getenv("LC_ALL")) && *s) || 78 if (((s = getenv("LC_ALL")) && *s) ||
79 ((s = getenv("LC_CTYPE")) && *s) || 79 ((s = getenv("LC_CTYPE")) && *s) ||
80 ((s = getenv("LANG")) && *s)) { 80 ((s = getenv("LANG")) && *s)) {
81 if (strstr(s, "UTF-8")) 81 if (strstr(s, "UTF-8"))
82 m_utf8mode = true; 82 m_utf8mode = true;
83 } 83 }
84 84
85 // create the right font implementation 85 // create the right font implementation
86 // antialias is prio 1 86 // antialias is prio 1
87#ifdef USE_XFT 87#ifdef USE_XFT
88 if (antialias) { 88 if (antialias) {
89 m_fontimp.reset(new XftFontImp(0, m_utf8mode)); 89 m_fontimp.reset(new XftFontImp(0, m_utf8mode));
90 m_antialias = true; 90 m_antialias = true;
91 } 91 }
92#endif //USE_XFT 92#endif //USE_XFT
93 // 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
94 if (m_fontimp.get() == 0) { 94 if (m_fontimp.get() == 0) {
95#ifdef USE_XMB 95#ifdef USE_XMB
96 if (m_multibyte || m_utf8mode) 96 if (m_multibyte || m_utf8mode)
97 m_fontimp.reset(new XmbFontImp(0, m_utf8mode)); 97 m_fontimp.reset(new XmbFontImp(0, m_utf8mode));
98 else // basic font implementation 98 else // basic font implementation
99#endif // USE_XMB 99#endif // USE_XMB
100 m_fontimp.reset(new XFontImp()); 100 m_fontimp.reset(new XFontImp());
101 } 101 }
102 102
103 if (name != 0) { 103 if (name != 0) {
104 load(name); 104 load(name);
105 } 105 }
106 106
107} 107}
108 108
@@ -111,74 +111,74 @@ Font::~Font() {
111} 111}
112 112
113void Font::setAntialias(bool flag) { 113void Font::setAntialias(bool flag) {
114 bool loaded = m_fontimp->loaded(); 114 bool loaded = m_fontimp->loaded();
115#ifdef USE_XFT 115#ifdef USE_XFT
116 if (flag && !isAntialias() && !m_rotated) { 116 if (flag && !isAntialias() && !m_rotated) {
117 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); 117 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode));
118 } else if (!flag && isAntialias()) 118 } else if (!flag && isAntialias())
119#endif // USE_XFT 119#endif // USE_XFT
120 { 120 {
121#ifdef USE_XMB 121#ifdef USE_XMB
122 if (m_multibyte || m_utf8mode) 122 if (m_multibyte || m_utf8mode)
123 m_fontimp.reset(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); 123 m_fontimp.reset(new XmbFontImp(m_fontstr.c_str(), m_utf8mode));
124 else 124 else
125#endif // USE_XMB 125#endif // USE_XMB
126 m_fontimp.reset(new XFontImp(m_fontstr.c_str())); 126 m_fontimp.reset(new XFontImp(m_fontstr.c_str()));
127 } 127 }
128 128
129 if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' 129 if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed'
130 if (!m_fontimp->load("fixed")) // if that failes too, output warning 130 if (!m_fontimp->load("fixed")) // if that failes too, output warning
131 cerr<<"Warning: can't load fallback font 'fixed'."<<endl; 131 cerr<<"Warning: can't load fallback font 'fixed'."<<endl;
132 } 132 }
133 133
134 m_antialias = flag; 134 m_antialias = flag;
135} 135}
136 136
137bool Font::load(const char *name) { 137bool Font::load(const char *name) {
138 if (name == 0) 138 if (name == 0)
139 return false; 139 return false;
140 m_fontstr = name; 140 m_fontstr = name;
141 return m_fontimp->load(name); 141 return m_fontimp->load(name);
142} 142}
143 143
144unsigned int Font::textWidth(const char * const text, unsigned int size) const { 144unsigned int Font::textWidth(const char * const text, unsigned int size) const {
145 return m_fontimp->textWidth(text, size); 145 return m_fontimp->textWidth(text, size);
146} 146}
147 147
148unsigned int Font::height() const { 148unsigned int Font::height() const {
149 return m_fontimp->height(); 149 return m_fontimp->height();
150} 150}
151 151
152int Font::ascent() const { 152int Font::ascent() const {
153 return m_fontimp->ascent(); 153 return m_fontimp->ascent();
154} 154}
155 155
156int Font::descent() const { 156int Font::descent() const {
157 return m_fontimp->descent(); 157 return m_fontimp->descent();
158} 158}
159void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { 159void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
160 if (text == 0 || len == 0) 160 if (text == 0 || len == 0)
161 return; 161 return;
162 m_fontimp->drawText(w, screen, gc, text, len, x, y); 162 m_fontimp->drawText(w, screen, gc, text, len, x, y);
163} 163}
164 164
165void Font::rotate(float angle) { 165void Font::rotate(float angle) {
166#ifdef USE_XFT 166#ifdef USE_XFT
167 // if we are rotated and we are changing to horiz text 167 // if we are rotated and we are changing to horiz text
168 // and we were antialiased before we rotated then change to XftFontImp 168 // and we were antialiased before we rotated then change to XftFontImp
169 if (isRotated() && angle == 0 && isAntialias()) 169 if (isRotated() && angle == 0 && isAntialias())
170 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); 170 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode));
171#endif // USE_XFT 171#endif // USE_XFT
172 // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment) 172 // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment)
173 // if we're going to rotate this font 173 // if we're going to rotate this font
174 if (angle != 0 && isAntialias() && !isRotated()) { 174 if (angle != 0 && isAntialias() && !isRotated()) {
175 m_fontimp.reset(new XFontImp(m_fontstr.c_str())); 175 m_fontimp.reset(new XFontImp(m_fontstr.c_str()));
176 } 176 }
177 177
178 //Note: only XFontImp implements FontImp::rotate 178 //Note: only XFontImp implements FontImp::rotate
179 m_fontimp->rotate(angle); 179 m_fontimp->rotate(angle);
180 180
181 m_rotated = (angle == 0 ? false : true); 181 m_rotated = (angle == 0 ? false : true);
182} 182}
183 183
184}; 184};