#include <font.hh>
Collaboration diagram for otk::Font:

Public Methods | |
| Font (int screen_num, const std::string &fontstring, bool shadow, unsigned char offset, unsigned char tint) | |
| virtual | ~Font () |
| const std::string & | fontstring () const |
| int | height () const |
| int | maxCharWidth () const |
| int | measureString (const ustring &string) const |
Static Public Methods | |
| std::string | fallbackFont (void) |
| void | setFallbackFont (const std::string &f) |
Private Methods | |
| bool | createXftFont (void) |
Private Attributes | |
| int | _screen_num |
| std::string | _fontstring |
| bool | _shadow |
| unsigned char | _offset |
| unsigned char | _tint |
| XftFont * | _xftfont |
Static Private Attributes | |
| std::string | _fallback_font = "fixed" |
| bool | _xft_init = false |
Friends | |
| class | RenderControl |
|
||||||||||||||||||||||||
|
Definition at line 36 of file font.cc. References _, _fallback_font, _fontstring, _xft_init, and _xftfont.
00038 : _screen_num(screen_num), 00039 _fontstring(fontstring), 00040 _shadow(shadow), 00041 _offset(offset), 00042 _tint(tint), 00043 _xftfont(0) 00044 { 00045 assert(screen_num >= 0); 00046 assert(tint <= CHAR_MAX); 00047 00048 if (!_xft_init) { 00049 if (!XftInit(0)) { 00050 printf(_("Couldn't initialize Xft.\n\n")); 00051 ::exit(3); 00052 } 00053 int version = XftGetVersion(); 00054 printf(_("Using Xft %d.%d.%d (Built against %d.%d.%d).\n"), 00055 version / 10000 % 100, version / 100 % 100, version % 100, 00056 XFT_MAJOR, XFT_MINOR, XFT_REVISION); 00057 _xft_init = true; 00058 } 00059 00060 if ((_xftfont = XftFontOpenName(**display, _screen_num, 00061 _fontstring.c_str()))) 00062 return; 00063 00064 printf(_("Unable to load font: %s\n"), _fontstring.c_str()); 00065 printf(_("Trying fallback font: %s\n"), _fallback_font.c_str()); 00066 00067 if ((_xftfont = XftFontOpenName(**display, _screen_num, 00068 _fallback_font.c_str()))) 00069 return; 00070 00071 printf(_("Unable to load font: %s\n"), _fallback_font.c_str()); 00072 printf(_("Aborting!.\n")); 00073 00074 ::exit(3); // can't continue without a font 00075 } |
|
|
Definition at line 78 of file font.cc.
00079 {
00080 if (_xftfont)
00081 XftFontClose(**display, _xftfont);
00082 }
|
|
|
|
|
|
Definition at line 32 of file font.hh.
00032 { return _fallback_font; }
|
|
|
Definition at line 58 of file font.hh.
00058 { return _fontstring; }
|
|
|
Definition at line 100 of file font.cc. References _offset, _shadow, and _xftfont. Referenced by otk::Label::fitString(), otk::FocusLabel::fitString(), otk::Label::update(), and otk::FocusLabel::update().
|
|
|
Definition at line 106 of file font.cc. References _xftfont.
00107 {
00108 return (signed) _xftfont->max_advance_width;
00109 }
|
|
|
Definition at line 85 of file font.cc. References _offset, _shadow, otk::ustring::bytes(), otk::ustring::c_str(), and otk::ustring::utf8(). Referenced by otk::Label::fitString(), otk::FocusLabel::fitString(), ob::LabelWidget::renderForeground(), otk::Label::renderForeground(), otk::FocusLabel::renderForeground(), otk::Label::update(), and otk::FocusLabel::update().
00086 {
00087 XGlyphInfo info;
00088
00089 if (string.utf8())
00090 XftTextExtentsUtf8(**display, _xftfont,
00091 (FcChar8*)string.c_str(), string.bytes(), &info);
00092 else
00093 XftTextExtents8(**display, _xftfont,
00094 (FcChar8*)string.c_str(), string.bytes(), &info);
00095
00096 return (signed) info.xOff + (_shadow ? _offset : 0);
00097 }
|
|
|
Definition at line 33 of file font.hh.
00034 { _fallback_font = f; }
|
|
|
|
|
|
Definition at line 33 of file font.cc. Referenced by Font(). |
|
|
Definition at line 42 of file font.hh. Referenced by Font(). |
|
|
Definition at line 45 of file font.hh. Referenced by otk::RenderControl::drawString(), height(), and measureString(). |
|
|
|
|
|
Definition at line 44 of file font.hh. Referenced by otk::RenderControl::drawString(), height(), and measureString(). |
|
|
Definition at line 46 of file font.hh. Referenced by otk::RenderControl::drawString(). |
|
|
Definition at line 34 of file font.cc. Referenced by Font(). |
|
|
Definition at line 48 of file font.hh. Referenced by otk::RenderControl::drawString(), Font(), height(), and maxCharWidth(). |
1.3-rc2