FbTk::Font Class Reference#include <Font.hh>
List of all members.
|
Public Member Functions |
|
| Font (const char *name=0, bool antialias=false) |
| bool | load (const std::string &name) |
|
void | setAntialias (bool flag) |
|
void | setShadow (bool flag) |
| unsigned int | textWidth (const char *const text, unsigned int size) const |
|
unsigned int | height () const |
|
int | ascent () const |
|
int | descent () const |
| void | rotate (float angle) |
| void | drawText (Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y, bool rotate=true) const |
|
bool | isAntialias () const |
|
bool | isRotated () const |
| | true if the font is rotated, else false
|
|
float | angle () const |
| | rotated angle
|
|
bool | shadow () const |
Static Public Member Functions |
|
bool | multibyte () |
| | true if multibyte is enabled, else false
|
|
bool | utf8 () |
| | true if utf-8 mode is enabled, else false
|
Detailed Description
Handles the client to fontimp bridge.
Definition at line 40 of file Font.hh.
Member Function Documentation
| void FbTk::Font::drawText |
( |
Drawable |
w, |
|
|
int |
screen, |
|
|
GC |
gc, |
|
|
const char * |
text, |
|
|
size_t |
len, |
|
|
int |
x, |
|
|
int |
y, |
|
|
bool |
rotate = true |
|
) |
const |
|
|
|
Draws text to drawable - Parameters:
-
| w | the drawable |
| screen | screen number |
| gc | Graphic Context |
| text | the text buffer |
| len | size of text buffer |
| x | position |
| y | position |
| rotate | if the text should be drawn rotated (if it's rotated before) |
Definition at line 200 of file Font.cc.
References FbTk::XFontImp::drawText(), FbTk::GContext::gc(), isRotated(), FbTk::GContext::setForeground(), and FbTk::XFontImp::setRotate().
00202 {
00203 if (text == 0 || len == 0)
00204 return;
00205
00206
00207 static bool first_run = true;
00208
00209
00210 if (first_run && m_shadow) {
00211 FbTk::GContext shadow_gc(w);
00212 shadow_gc.setForeground(FbTk::Color("black", screen));
00213 first_run = false;
00214 drawText(w, screen, shadow_gc.gc(), text, len, x + 1, y + 1);
00215 first_run = true;
00216 }
00217
00218 if (!rotate && isRotated()) {
00219
00220
00221
00222
00223
00224 try {
00225 XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp.get());
00226 font->setRotate(false);
00227
00228 font->drawText(w, screen, gc, text, len, x, y);
00229 font->setRotate(true);
00230 } catch (std::bad_cast &bc) {
00231
00232 m_fontimp->drawText(w, screen, gc, text, len, x, y);
00233 }
00234
00235 } else
00236 m_fontimp->drawText(w, screen, gc, text, len, x, y);
00237
00238
00239 }
|
| bool FbTk::Font::load |
( |
const std::string & |
name |
) |
|
|
|
|
Load a font - Returns:
- true on success, else false and it'll fall back on the last loaded font
Definition at line 140 of file Font.cc.
00140 {
00141 if (name.size() == 0)
00142 return false;
00143
00144 std::string new_name = name;
00145
00146 m_shadow = false;
00147
00148
00149 size_t start_pos = new_name.find_first_of(':');
00150 if (start_pos != std::string::npos) {
00151 size_t shadow_pos = new_name.find("shadow", start_pos);
00152 if (shadow_pos != std::string::npos) {
00153 m_shadow = true;
00154
00155 new_name.erase(shadow_pos, 6);
00156
00157
00158 if (new_name.find_first_not_of("\t ,", start_pos + 1) == std::string::npos)
00159 new_name.erase(start_pos);
00160 else {
00161
00162
00163 size_t pos = new_name.find_last_not_of("\t ", shadow_pos);
00164 if (pos != std::string::npos) {
00165 if (new_name[pos] == ',')
00166 new_name.erase(pos, 1);
00167
00168 }
00169
00170
00171
00172
00173 if (new_name.find_first_not_of("\t ", start_pos + 1) == std::string::npos)
00174 new_name.erase(start_pos, 1);
00175
00176 }
00177
00178 }
00179 }
00180
00181 m_fontstr = name;
00182 return m_fontimp->load(new_name.c_str());
00183 }
|
| void FbTk::Font::rotate |
( |
float |
angle |
) |
|
|
|
|
Rotate font in any angle (currently only 90 degrees supported and just XFont implementation)
Definition at line 241 of file Font.cc.
References isRotated().
00241 {
00242 #ifdef USE_XFT
00243
00244
00245 if (isRotated() && angle == 0 && isAntialias())
00246 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode));
00247 #endif // USE_XFT
00248
00249
00250 if (angle != 0 && isAntialias() && !isRotated()) {
00251 m_fontimp.reset(new XFontImp(m_fontstr.c_str()));
00252 if (!m_fontimp->loaded())
00253 m_fontimp->load("fixed");
00254 }
00255
00256
00257 m_fontimp->rotate(angle);
00258
00259 m_rotated = (angle == 0 ? false : true);
00260 m_angle = angle;
00261 }
|
| unsigned int FbTk::Font::textWidth |
( |
const char *const |
text, |
|
|
unsigned int |
size |
|
) |
const |
|
|
|
- Parameters:
-
| text | text to check size |
| size | length of text in bytes |
- Returns:
- size of text in pixels
Definition at line 185 of file Font.cc.
Referenced by FbTk::doAlignment(), and FbTk::Menu::drawItem().
00185 {
00186 return m_fontimp->textWidth(text, size);
00187 }
|
The documentation for this class was generated from the following files:
Fluxbox CVS-Jan-2003
|
|
|