all repos — fluxbox @ 3a79de034f87df155f540af2186c5d87dc187b3b

custom fork of the fluxbox windowmanager

change default Xft font so that it works properly with rotation (see 
notes in ChangeLog or FbTk/Font.cc)
simonb simonb
commit

3a79de034f87df155f540af2186c5d87dc187b3b

parent

87b8626793e25a8ab4b1e077fcf29cb06ff7f71c

M ChangeLogChangeLog

@@ -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: <bitmask>, where the bitmask corresponds
M src/FbTk/Font.ccsrc/FbTk/Font.cc

@@ -197,21 +197,44 @@ }

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;
M src/FbTk/Font.hhsrc/FbTk/Font.hh

@@ -56,7 +56,7 @@ static bool utf8() { return s_utf8mode; }

- explicit Font(const char *name = "fixed"); + explicit Font(const char *name = "__DEFAULT__"); virtual ~Font(); /** Load a font
M src/FbTk/ThemeItems.ccsrc/FbTk/ThemeItems.cc

@@ -120,7 +120,7 @@ }

template <> void ThemeItem<Font>::setDefaultValue() { - if (!m_value.load("fixed")) { + if (!m_value.load("__DEFAULT__")) { cerr<<"ThemeItem<Font>: Warning! Failed to load default value 'fixed'"<<endl; } else { string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect"));
M src/FbTk/XftFontImp.ccsrc/FbTk/XftFontImp.cc

@@ -63,8 +63,10 @@ }

// destroy all old fonts and set new for (int r = ROT0; r <= ROT270; r++) - if (m_xftfonts[r] != 0) + if (m_xftfonts[r] != 0) { XftFontClose(App::instance()->display(), m_xftfonts[r]); + m_xftfonts[r] = 0; + } m_xftfonts[ROT0] = newxftfont; m_name = name;

@@ -73,6 +75,7 @@ return true;

} 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 @@

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;
M src/FbWinFrameTheme.ccsrc/FbWinFrameTheme.cc

@@ -69,7 +69,7 @@ m_unfocused_alpha(255) {

*m_title_height = 0; // set defaults - m_font->load("fixed"); + m_font->load("__DEFAULT__"); // create cursors Display *disp = FbTk::App::instance()->display();