change default Xft font so that it works properly with rotation (see

notes in ChangeLog or FbTk/Font.cc)
This commit is contained in:
simonb 2007-01-05 13:01:19 +00:00
parent 87b8626793
commit 3a79de034f
6 changed files with 54 additions and 18 deletions

View file

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

View file

@ -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) {
#ifdef USE_XMB
if (s_multibyte || s_utf8mode)
tmp_font = new XmbFontImp(0, s_utf8mode);
else // basic font implementation
#endif // USE_XMB
tmp_font = new XFontImp();
}
if (tmp_font && tmp_font->load((*name_it).c_str())) {
if (!tmp_font) {
if (*name_it == "__DEFAULT__")
realname = "fixed";
#ifdef USE_XMB
if (s_multibyte || s_utf8mode) {
tmp_font = new XmbFontImp(0, s_utf8mode);
} else // basic font implementation
#endif // USE_XMB
{
tmp_font = new XFontImp();
}
}
if (tmp_font && tmp_font->load(realname.c_str())) {
lookup_map[name] = (*name_it);
m_fontimp = tmp_font;
font_cache[(*name_it)] = tmp_font;

View file

@ -56,7 +56,7 @@ public:
explicit Font(const char *name = "fixed");
explicit Font(const char *name = "__DEFAULT__");
virtual ~Font();
/**
Load a font

View file

@ -120,7 +120,7 @@ void ThemeItem<unsigned int>::load(const std::string *name, const std::string *a
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"));

View file

@ -63,8 +63,10 @@ bool XftFontImp::load(const std::string &name) {
// 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 @@ 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;

View file

@ -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();