aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Font.cc33
-rw-r--r--src/FbTk/Font.hh2
-rw-r--r--src/FbTk/ThemeItems.cc2
-rw-r--r--src/FbTk/XftFontImp.cc12
-rw-r--r--src/FbWinFrameTheme.cc2
5 files changed, 38 insertions, 13 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index 47883e1..156c812 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -197,21 +197,44 @@ bool Font::load(const string &name) {
197 197
198 FontImp* tmp_font(0); 198 FontImp* tmp_font(0);
199 199
200 // Xft and X/Xmb fonts have different defaults
201 // (fixed doesn't really work right with Xft, especially rotated)
202
203 // HOWEVER, note that if a Xft-style font is requested (not start with "-"), and
204 // it turns out to be a bitmapped XFont, then Xft will load it, BUT it does not
205 // currently (5jan2007) rotate bitmapped fonts (ok-ish), nor adjust the baseline for its
206 // lack of rotation (not ok: messes up placement). I can't see a neat way around this,
207 // other than the user re-specifying their font explicitly in XFont form so we don't use the
208 // Xft backend.
209
210 std::string realname = *name_it;
211
200#ifdef USE_XFT 212#ifdef USE_XFT
201 if ((*name_it)[0] != '-') 213 if ((*name_it)[0] != '-') {
214
215 if (*name_it == "__DEFAULT__")
216 realname = "monospace";
217
202 tmp_font = new XftFontImp(0, s_utf8mode); 218 tmp_font = new XftFontImp(0, s_utf8mode);
203#endif // USE_XFT 219#endif // USE_XFT
220 }
204 221
205 if (!tmp_font) { 222 if (!tmp_font) {
223 if (*name_it == "__DEFAULT__")
224 realname = "fixed";
225
206#ifdef USE_XMB 226#ifdef USE_XMB
207 if (s_multibyte || s_utf8mode) 227
228 if (s_multibyte || s_utf8mode) {
208 tmp_font = new XmbFontImp(0, s_utf8mode); 229 tmp_font = new XmbFontImp(0, s_utf8mode);
209 else // basic font implementation 230 } else // basic font implementation
210#endif // USE_XMB 231#endif // USE_XMB
211 tmp_font = new XFontImp(); 232 {
233 tmp_font = new XFontImp();
234 }
212 } 235 }
213 236
214 if (tmp_font && tmp_font->load((*name_it).c_str())) { 237 if (tmp_font && tmp_font->load(realname.c_str())) {
215 lookup_map[name] = (*name_it); 238 lookup_map[name] = (*name_it);
216 m_fontimp = tmp_font; 239 m_fontimp = tmp_font;
217 font_cache[(*name_it)] = tmp_font; 240 font_cache[(*name_it)] = tmp_font;
diff --git a/src/FbTk/Font.hh b/src/FbTk/Font.hh
index eadde6f..4806c43 100644
--- a/src/FbTk/Font.hh
+++ b/src/FbTk/Font.hh
@@ -56,7 +56,7 @@ public:
56 56
57 57
58 58
59 explicit Font(const char *name = "fixed"); 59 explicit Font(const char *name = "__DEFAULT__");
60 virtual ~Font(); 60 virtual ~Font();
61 /** 61 /**
62 Load a font 62 Load a font
diff --git a/src/FbTk/ThemeItems.cc b/src/FbTk/ThemeItems.cc
index 2f58b2a..6d2b244 100644
--- a/src/FbTk/ThemeItems.cc
+++ b/src/FbTk/ThemeItems.cc
@@ -120,7 +120,7 @@ void ThemeItem<unsigned int>::load(const std::string *name, const std::string *a
120 120
121template <> 121template <>
122void ThemeItem<Font>::setDefaultValue() { 122void ThemeItem<Font>::setDefaultValue() {
123 if (!m_value.load("fixed")) { 123 if (!m_value.load("__DEFAULT__")) {
124 cerr<<"ThemeItem<Font>: Warning! Failed to load default value 'fixed'"<<endl; 124 cerr<<"ThemeItem<Font>: Warning! Failed to load default value 'fixed'"<<endl;
125 } else { 125 } else {
126 string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect")); 126 string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect"));
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc
index 40b9b9e..5acf0af 100644
--- a/src/FbTk/XftFontImp.cc
+++ b/src/FbTk/XftFontImp.cc
@@ -63,8 +63,10 @@ bool XftFontImp::load(const std::string &name) {
63 63
64 // destroy all old fonts and set new 64 // destroy all old fonts and set new
65 for (int r = ROT0; r <= ROT270; r++) 65 for (int r = ROT0; r <= ROT270; r++)
66 if (m_xftfonts[r] != 0) 66 if (m_xftfonts[r] != 0) {
67 XftFontClose(App::instance()->display(), m_xftfonts[r]); 67 XftFontClose(App::instance()->display(), m_xftfonts[r]);
68 m_xftfonts[r] = 0;
69 }
68 70
69 m_xftfonts[ROT0] = newxftfont; 71 m_xftfonts[ROT0] = newxftfont;
70 m_name = name; 72 m_name = name;
@@ -73,6 +75,7 @@ bool XftFontImp::load(const std::string &name) {
73} 75}
74 76
75void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { 77void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const {
78
76 if (m_xftfonts[orient] == 0) 79 if (m_xftfonts[orient] == 0)
77 return; 80 return;
78 81
@@ -223,11 +226,10 @@ bool XftFontImp::validOrientation(FbTk::Orientation orient) {
223 Display *disp = App::instance()->display(); 226 Display *disp = App::instance()->display();
224 227
225 XftPattern * pattern = XftNameParse(m_name.c_str()); 228 XftPattern * pattern = XftNameParse(m_name.c_str());
226 XftPatternAddMatrix(pattern, XFT_MATRIX, &matrix);
227 XftResult result; 229 XftResult result;
228 XftPattern * foundpat = XftFontMatch(disp, 0, pattern, &result); 230 pattern = XftFontMatch(disp, 0, pattern, &result);
229 XftPatternDestroy(pattern); 231 XftPatternAddMatrix(pattern, XFT_MATRIX, &matrix);
230 XftFont * new_font = XftFontOpenPattern(disp, foundpat); 232 XftFont * new_font = XftFontOpenPattern(disp, pattern);
231 233
232 if (new_font == 0) 234 if (new_font == 0)
233 return false; 235 return false;
diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc
index 898171f..72f42fe 100644
--- a/src/FbWinFrameTheme.cc
+++ b/src/FbWinFrameTheme.cc
@@ -69,7 +69,7 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num):
69 69
70 *m_title_height = 0; 70 *m_title_height = 0;
71 // set defaults 71 // set defaults
72 m_font->load("fixed"); 72 m_font->load("__DEFAULT__");
73 73
74 // create cursors 74 // create cursors
75 Display *disp = FbTk::App::instance()->display(); 75 Display *disp = FbTk::App::instance()->display();