diff options
author | simonb <simonb> | 2007-01-05 13:01:19 (GMT) |
---|---|---|
committer | simonb <simonb> | 2007-01-05 13:01:19 (GMT) |
commit | 3a79de034f87df155f540af2186c5d87dc187b3b (patch) | |
tree | 9352aebc02ecc46ec475e1a2764c8f39cd732453 /src/FbTk | |
parent | 87b8626793e25a8ab4b1e077fcf29cb06ff7f71c (diff) | |
download | fluxbox_paul-3a79de034f87df155f540af2186c5d87dc187b3b.zip fluxbox_paul-3a79de034f87df155f540af2186c5d87dc187b3b.tar.bz2 |
change default Xft font so that it works properly with rotation (see
notes in ChangeLog or FbTk/Font.cc)
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Font.cc | 33 | ||||
-rw-r--r-- | src/FbTk/Font.hh | 2 | ||||
-rw-r--r-- | src/FbTk/ThemeItems.cc | 2 | ||||
-rw-r--r-- | src/FbTk/XftFontImp.cc | 12 |
4 files changed, 37 insertions, 12 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 | ||
121 | template <> | 121 | template <> |
122 | void ThemeItem<Font>::setDefaultValue() { | 122 | void 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 | ||
75 | void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { | 77 | void 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; |