From 3a79de034f87df155f540af2186c5d87dc187b3b Mon Sep 17 00:00:00 2001 From: simonb Date: Fri, 5 Jan 2007 13:01:19 +0000 Subject: change default Xft font so that it works properly with rotation (see notes in ChangeLog or FbTk/Font.cc) --- ChangeLog | 11 +++++++++++ src/FbTk/Font.cc | 33 ++++++++++++++++++++++++++++----- src/FbTk/Font.hh | 2 +- src/FbTk/ThemeItems.cc | 2 +- src/FbTk/XftFontImp.cc | 12 +++++++----- src/FbWinFrameTheme.cc | 2 +- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7ab7f1..6e200a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*07/01/05: + * Change default Xft font to "monospace" (was "fixed") (Simon) + - The "fixed" font loads a bitmap Xfont + - Note that bitmap fonts do not rotate properly, and especially the + baseline isn't adjusted for the lack of rotation. Thus we recommend + that if you are using a bitmapped font (e.g. artwiz), then specify it + using xfld style (-*-snap-*-*-* ...etc) so that fluxbox loads it with + traditional XFont/XmbFont calls, resulting in correct placement and + rotation. + FbTk/... Font.hh/cc XftFontImp.cc ThemeItems.cc + FbWinFrameTheme.cc *07/01/04: * Added new resource for init file to control default window decorations: session.screenN.defaultDeco: , where the bitmask corresponds 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) { FontImp* tmp_font(0); + // Xft and X/Xmb fonts have different defaults + // (fixed doesn't really work right with Xft, especially rotated) + + // HOWEVER, note that if a Xft-style font is requested (not start with "-"), and + // it turns out to be a bitmapped XFont, then Xft will load it, BUT it does not + // currently (5jan2007) rotate bitmapped fonts (ok-ish), nor adjust the baseline for its + // lack of rotation (not ok: messes up placement). I can't see a neat way around this, + // other than the user re-specifying their font explicitly in XFont form so we don't use the + // Xft backend. + + std::string realname = *name_it; + #ifdef USE_XFT - if ((*name_it)[0] != '-') + if ((*name_it)[0] != '-') { + + if (*name_it == "__DEFAULT__") + realname = "monospace"; + tmp_font = new XftFontImp(0, s_utf8mode); #endif // USE_XFT + } if (!tmp_font) { + if (*name_it == "__DEFAULT__") + realname = "fixed"; + #ifdef USE_XMB - if (s_multibyte || s_utf8mode) + + if (s_multibyte || s_utf8mode) { tmp_font = new XmbFontImp(0, s_utf8mode); - else // basic font implementation + } else // basic font implementation #endif // USE_XMB - tmp_font = new XFontImp(); + { + tmp_font = new XFontImp(); + } } - if (tmp_font && tmp_font->load((*name_it).c_str())) { + if (tmp_font && tmp_font->load(realname.c_str())) { lookup_map[name] = (*name_it); m_fontimp = tmp_font; 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: - explicit Font(const char *name = "fixed"); + explicit Font(const char *name = "__DEFAULT__"); virtual ~Font(); /** 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::load(const std::string *name, const std::string *a template <> void ThemeItem::setDefaultValue() { - if (!m_value.load("fixed")) { + if (!m_value.load("__DEFAULT__")) { cerr<<"ThemeItem: Warning! Failed to load default value 'fixed'"<display(), m_xftfonts[r]); + m_xftfonts[r] = 0; + } m_xftfonts[ROT0] = newxftfont; m_name = name; @@ -73,6 +75,7 @@ bool XftFontImp::load(const std::string &name) { } void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { + if (m_xftfonts[orient] == 0) return; @@ -223,11 +226,10 @@ bool XftFontImp::validOrientation(FbTk::Orientation orient) { Display *disp = App::instance()->display(); XftPattern * pattern = XftNameParse(m_name.c_str()); - XftPatternAddMatrix(pattern, XFT_MATRIX, &matrix); XftResult result; - XftPattern * foundpat = XftFontMatch(disp, 0, pattern, &result); - XftPatternDestroy(pattern); - XftFont * new_font = XftFontOpenPattern(disp, foundpat); + pattern = XftFontMatch(disp, 0, pattern, &result); + XftPatternAddMatrix(pattern, XFT_MATRIX, &matrix); + XftFont * new_font = XftFontOpenPattern(disp, pattern); if (new_font == 0) 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): *m_title_height = 0; // set defaults - m_font->load("fixed"); + m_font->load("__DEFAULT__"); // create cursors Display *disp = FbTk::App::instance()->display(); -- cgit v0.11.2