all repos — fluxbox @ ef76b45ab1857af1b12f0c336bfb8c0f19140aeb

custom fork of the fluxbox windowmanager

- Usage of xft-fonts is prefered, except a font-description starts with '-'
- Removed "antialias"-option completly, to enable/disable "antialias"
  use either  <fontname>:antialias=<bool> in the style or use
  Xft.antialias: <bool> in your .Xdefaults
- Added new styleresources: 
    *.font.effect: <halo|shadow>
    *.font.shadow.x : <int>       - shadow x offset
    *.font.shadow.y : <int>       - shadow y offset
    *.font.shadow.color : <color> - color of shadow
    *.font.halo.color : <color>   - color of halo
- Removed 'shadow' and 'halo' options from fontdefinitions:
    !! Style authors have to update their styles !!
- Simplified XmbFontImp to not try all possible fonts to match locale
- Style authors may specify multiple fonts:
    <font1>|<font2>|<font3>
  if loading of font1 fails, fluxbox probes <font2>, etc. The last font is
  "fixed". Hints for style authors:
    - if xft tries to load a font it will _ALWAYS_ return a valid font,
      it doesnt have to look like the one you want to have, read more
      about it: http://fontconfig.org/fontconfig-user.html
    - export XFT_DEBUG=1  before running fluxbox helps to see
      which fonts are picked.
  eg:
      *.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*-
      if fluxbox is compiled with xft this will NEVER try to
      load "-artwiz-snap-*-" since xft gives for sure a font,
      most likely Verdana or Arial but noone knows. So, if
      fluxbox has no xft support the first fontpattern fails
      and fluxbox tries the next one, which might be successful.
      if everything fails, it will use "fixed"
- Added caching of fonts, fonts are only loaded once.
- Fixed #1090902 (slow utf8 start)
mathias mathias
commit

ef76b45ab1857af1b12f0c336bfb8c0f19140aeb

parent

9c27e2e7993c9ccd604f77219a1f07c1be22e75a

M ChangeLogChangeLog

@@ -1,5 +1,43 @@

(Format: Year/Month/Day) Changes for 0.9.14: +*05/06/03: + * Massive change of font handling (Mathias) + - Usage of xft-fonts is prefered, except a font-description starts with '-' + - Removed "antialias"-option completly, to enable/disable "antialias" + use either <fontname>:antialias=<bool> in the style or use + Xft.antialias: <bool> in your .Xdefaults + - Added new styleresources: + *.font.effect: <halo|shadow> + *.font.shadow.x : <int> - shadow x offset + *.font.shadow.y : <int> - shadow y offset + *.font.shadow.color : <color> - color of shadow + *.font.halo.color : <color> - color of halo + - Removed 'shadow' and 'halo' options from fontdefinitions: + !! Style authors have to update their styles !! + - Simplified XmbFontImp to not try all possible fonts to match locale + - Style authors may specify multiple fonts: + <font1>|<font2>|<font3> + if loading of font1 fails, fluxbox probes <font2>, etc. The last font is + "fixed". Hints for style authors: + - if xft tries to load a font it will _ALWAYS_ return a valid font, + it doesnt have to look like the one you want to have, read more + about it: http://fontconfig.org/fontconfig-user.html + - export XFT_DEBUG=1 before running fluxbox helps to see + which fonts are picked. + eg: + *.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*- + if fluxbox is compiled with xft this will NEVER try to + load "-artwiz-snap-*-" since xft gives for sure a font, + most likely Verdana or Arial but noone knows. So, if + fluxbox has no xft support the first fontpattern fails + and fluxbox tries the next one, which might be successful. + if everything fails, it will use "fixed" + - Added caching of fonts, fonts are only loaded once. + - Fixed #1090902 + ToolFactory.cc TextTheme.hh/cc IconbarTheme.cc Screen.hh/cc + FbTk/Font.hh/cc FbTk/XftFontImp.cc FbTk/XmbFontImp.cc + FbTk/MenuTheme.cc FbTk/Texture.cc FbTk/ThemeItems.cc + fbrun/main.cc fbrun/FbRun.cc *05/06/02: * Fixed _BLACKBOX_NOTIFY_WINDOW_ADD issue (thanx Vadim) _BLACKBOX_NOTIFY_WINDOW_ADD was emited before _NET_CLIENT_LIST
M src/FbTk/Font.ccsrc/FbTk/Font.cc

@@ -27,6 +27,7 @@ #include "stringstream.hh"

#include "Font.hh" #include "FontImp.hh" #include "I18n.hh" +#include "App.hh" #ifdef HAVE_CONFIG_H #include "config.h"

@@ -67,6 +68,7 @@ #else

#include <stdlib.h> #endif #include <list> +#include <map> #include <typeinfo> #include <langinfo.h>

@@ -148,69 +150,15 @@ return 0;

} #endif // HAVE_ICONV -int extract_halo_options(const std::string& opts, std::string& color) { - std::list< std::string > tokens; - size_t sep= opts.find_first_of(':'); - - if ( sep == std::string::npos ) - return 1; - - FbTk::StringUtil::stringtok(tokens, opts.substr(sep + 1, opts.length()), ";"); - tokens.unique(); - std::list< std::string >::const_iterator token; - - for ( token= tokens.begin(); token != tokens.end(); token++ ) { - if ( (*token).find("color=", 0) != std::string::npos ) { - size_t s= (*token).find_first_of('='); - std::string c= (*token).substr(s + 1, (*token).length()); - if ( !c.empty() ) - std::swap(color, c); - } - } - - return 1; -} - -int extract_shadow_options(const std::string& opts, - std::string& color, - int& offx, int& offy) { - - std::list< std::string > tokens; - size_t sep= opts.find_first_of(':'); - - if ( sep == std::string::npos ) - return 1; - - FbTk::StringUtil::stringtok(tokens, opts.substr(sep + 1, opts.length()), ";"); - tokens.unique(); - std::list< std::string >::const_iterator token; - - for ( token= tokens.begin(); token != tokens.end(); token++ ) { - if ( (*token).find("color=", 0) != std::string::npos ) { - size_t s= (*token).find_first_of('='); - std::string c= (*token).substr(s + 1, (*token).length()); - if ( !c.empty() ) - std::swap(color, c); - } - else if ( (*token).find("offsetx=", 0) != std::string::npos ) { - size_t s= (*token).find_first_of('='); - FbTk_istringstream o((*token).substr(s + 1, (*token).length()).c_str()); - if ( !o.eof() ) { - o >> offx; - } - } - else if ( (*token).find("offsety=", 0) != std::string::npos ) { - size_t s= (*token).find_first_of('='); - FbTk_istringstream o((*token).substr(s + 1, (*token).length()).c_str()); - if ( !o.eof() ) { - o >> offy; - } - } - } - - return 1; +// use to map <font1>|<font2>|<font3> => <fontthatworks> +typedef std::map<std::string, std::string> StringMap; +typedef StringMap::iterator StringMapIt; +StringMap lookup_map; -}; +// stores <fontthatworks and the fontimp +typedef std::map<std::string, FbTk::FontImp* > FontCache; +typedef FontCache::iterator FontCacheIt; +FontCache font_cache; }; // end nameless namespace

@@ -218,8 +166,8 @@

namespace FbTk { -bool Font::m_multibyte = false; -bool Font::m_utf8mode = false; +bool Font::s_multibyte = false; +bool Font::s_utf8mode = false; void Font::init() {

@@ -229,24 +177,34 @@ }

void Font::shutdown() { + FontCacheIt fit; + for (fit = font_cache.begin(); fit != font_cache.end(); fit++) { + FontImp* font = fit->second; + if (font) { + FontCacheIt it; + for (it = fit; it != font_cache.end(); it++) + if (it->second == font) + it->second = 0; + delete font; + } + } } -Font::Font(const char *name, bool antialias): +Font::Font(const char *name): m_fontimp(0), - m_antialias(false), m_rotated(false), - m_shadow(false), m_shadow_color("#000000"), - m_shadow_offx(1), m_shadow_offy(1), - m_halo(false), m_halo_color("#ffffff"), + m_rotated(false), + m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())), + m_shadow_offx(2), m_shadow_offy(2), + m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display())), #ifdef HAVE_ICONV m_iconv((iconv_t)(-1)) #else m_iconv(-1) #endif // HAVE_ICONV { - // MB_CUR_MAX returns the size of a char in the current locale if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte - m_multibyte = true; + s_multibyte = true; // check for utf-8 mode #ifdef CODESET

@@ -256,7 +214,7 @@ char *locale_codeset = 0;

#endif // CODESET if (locale_codeset && strcmp("UTF-8", locale_codeset) == 0) { - m_utf8mode = true; + s_utf8mode = true; } else if (locale_codeset != 0) { // if locale isn't UTF-8 we try to // create a iconv pointer so we can

@@ -272,13 +230,13 @@ if(m_iconv == (iconv_t)(-1)) {

cerr<<"FbTk::Font: code error: from "<<locale_codeset<<" to: UTF-8"<<endl; // if we failed with iconv then we can't convert // the strings to utf-8, so we disable utf8 mode - m_utf8mode = false; + s_utf8mode = false; } else { // success, we can now enable utf8mode // and if antialias is on later we can recode // the non utf-8 string to utf-8 and use utf-8 // drawing functions - m_utf8mode = true; + s_utf8mode = true; } #endif // HAVE_ICONV }

@@ -287,23 +245,6 @@ #ifdef DEBUG

cerr<<"FbTk::Font m_iconv = "<<(int)m_iconv<<endl; #endif // DEBUG - // create the right font implementation - // antialias is prio 1 -#ifdef USE_XFT - if (antialias) { - m_fontimp.reset(new XftFontImp(0, m_utf8mode)); - } -#endif //USE_XFT - // if we didn't create a Xft font then create basic font - if (m_fontimp.get() == 0) { -#ifdef USE_XMB - if (m_multibyte || m_utf8mode) - m_fontimp.reset(new XmbFontImp(0, m_utf8mode)); - else // basic font implementation -#endif // USE_XMB - m_fontimp.reset(new XFontImp()); - } - if (name != 0) { load(name); }

@@ -317,82 +258,68 @@ iconv_close(m_iconv);

#endif // HAVE_ICONV } -void Font::setAntialias(bool flag) { - bool loaded = m_fontimp->loaded(); -#ifdef USE_XFT - if (flag && !isAntialias() && !m_rotated) { - m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); - } else if (!flag && isAntialias()) -#endif // USE_XFT - { -#ifdef USE_XMB - if (m_multibyte || m_utf8mode) - m_fontimp.reset(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); - else -#endif // USE_XMB - m_fontimp.reset(new XFontImp(m_fontstr.c_str())); - } - - if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' - if (!m_fontimp->load("fixed")) {// if that failes too, output warning - _FB_USES_NLS; - cerr<<_FBTKTEXT(Error, CantFallbackFont, "Warning: can't load fallback font", "Attempt to load the last-resort default font failed")<<" 'fixed'."<<endl; - } - } - - m_antialias = flag; -} - bool Font::load(const std::string &name) { if (name.size() == 0) return false; - // default values for font options - m_shadow = false; - m_halo = false; + + StringMapIt lookup_entry; + FontCacheIt cache_entry; - // everything after ':' is a fontoption - // -> extract 'halo' and 'shadow' and - // load remaining fname - size_t sep= name.find_first_of(':'); + // check if one of <font1>|<font2>|<font3> is already there + if ((lookup_entry = lookup_map.find(name)) != lookup_map.end() && + (cache_entry = font_cache.find(lookup_entry->second)) != font_cache.end()) { + m_fontstr = cache_entry->first; + m_fontimp = cache_entry->second; + return true; + } + + // split up the namelist + typedef std::list<std::string> StringList; + typedef StringList::iterator StringListIt; + StringList names; + FbTk::StringUtil::stringtok<StringList>(names, name, "|"); + + StringListIt name_it; + for (name_it = names.begin(); name_it != names.end(); name_it++) { + FbTk::StringUtil::removeTrailingWhitespace(*name_it); + FbTk::StringUtil::removeFirstWhitespace(*name_it); - if ( sep != std::string::npos ) { + if ((cache_entry = font_cache.find(*name_it)) != font_cache.end()) { + m_fontstr = cache_entry->first; + m_fontimp = cache_entry->second; + lookup_map[name] = m_fontstr; + return true; + } - std::list< std::string > tokens; - std::string fname; - - fname= std::string(name.c_str(), sep); - - FbTk::StringUtil::stringtok(tokens, name.substr(sep + 1), ","); - - tokens.unique(); - bool firstone= true; - std::list< std::string >::const_iterator token; + FontImp* tmp_font(0); + +#ifdef USE_XFT + if ((*name_it)[0] != '-') + 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(); + } - // check tokens and extract extraoptions for halo and shadow - for( token= tokens.begin(); token != tokens.end(); token++ ) { - if ( (*token).find("halo",0) != std::string::npos ) { - m_halo= true; - extract_halo_options(*token, m_halo_color); - } - else if ( (*token).find("shadow", 0) != std::string::npos ) { - m_shadow= true; - extract_shadow_options(*token, m_shadow_color, m_shadow_offx, m_shadow_offy); - } - else { - if ( !firstone ) - fname+= ", "; - else - firstone= false; - fname= fname + ":" + *token; - } + if (tmp_font && tmp_font->load((*name_it).c_str())) { + lookup_map[name] = (*name_it); + m_fontimp = tmp_font; + font_cache[(*name_it)] = tmp_font; + m_fontstr = name; + return true; } - - m_fontstr = fname; - } else - m_fontstr = name; + + delete tmp_font; + } - return m_fontimp->load(m_fontstr.c_str()); + return false;; } unsigned int Font::textWidth(const char * const text, unsigned int size) const {

@@ -449,14 +376,14 @@ // draw "effects" first

if (first_run) { if (m_shadow) { FbTk::GContext shadow_gc(w); - shadow_gc.setForeground(FbTk::Color(m_shadow_color.c_str(), screen)); + shadow_gc.setForeground(m_shadow_color); first_run = false; drawText(w, screen, shadow_gc.gc(), real_text, len, x + m_shadow_offx, y + m_shadow_offy, rotate); first_run = true; } else if (m_halo) { FbTk::GContext halo_gc(w); - halo_gc.setForeground(FbTk::Color(m_halo_color.c_str(), screen)); + halo_gc.setForeground(m_halo_color); first_run = false; drawText(w, screen, halo_gc.gc(), real_text, len, x + 1, y + 1, rotate); drawText(w, screen, halo_gc.gc(), real_text, len, x - 1, y + 1, rotate);

@@ -473,7 +400,7 @@ // currently just XFontImp

// Using dynamic_cast just temporarly until there's a better solution // to put in FontImp try { - XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp.get()); + XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp); font->setRotate(false); // disable rotation temporarly font->drawText(w, screen, gc, real_text, len, x, y);

@@ -492,15 +419,16 @@

} void Font::rotate(float angle) { +/* TODO: reimplement rotated text #ifdef USE_XFT // if we are rotated and we are changing to horiz text // and we were antialiased before we rotated then change to XftFontImp - if (isRotated() && angle == 0 && isAntialias()) - m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); + if (isRotated() && angle == 0 && !m_xftfontstr.empty()) + m_fontimp.reset(new XftFontImp(m_fontstr.c_str(),s_utf8mode)); #endif // USE_XFT // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment) // if we're going to rotate this font - if (angle != 0 && isAntialias() && !isRotated()) { + if (angle != 0 && !isRotated()) { m_fontimp.reset(new XFontImp(m_fontstr.c_str())); if (!m_fontimp->loaded()) // if it failed to load font, try default font fixed m_fontimp->load("fixed");

@@ -511,6 +439,7 @@ m_fontimp->rotate(angle);

m_rotated = (angle == 0 ? false : true); m_angle = angle; + */ }
M src/FbTk/Font.hhsrc/FbTk/Font.hh

@@ -28,7 +28,6 @@ #include <X11/Xlib.h>

#include <X11/Xresource.h> #include <string> -#include <memory> #ifdef HAVE_CONFIG_H #include "config.h"

@@ -37,6 +36,8 @@

#ifdef HAVE_ICONV #include <iconv.h> #endif // HAVE_ICONV + +#include "Color.hh" namespace FbTk {

@@ -56,13 +57,13 @@ /// called at FbTk::App destruction time, cleans up what was inited first

static void shutdown(); /// @return true if multibyte is enabled, else false - static bool multibyte() { return m_multibyte; } + static bool multibyte() { return s_multibyte; } /// @return true if utf-8 mode is enabled, else false - static bool utf8() { return m_utf8mode; } + static bool utf8() { return s_utf8mode; } - Font(const char *name=0, bool antialias = false); + Font(const char *name = "fixed"); virtual ~Font(); /** Load a font

@@ -70,10 +71,15 @@ @return true on success, else false and it'll fall back on the last

loaded font */ bool load(const std::string &name); - - void setAntialias(bool flag); - inline void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); } - inline void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); } + + void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); } + void setHaloColor(const Color& color) { m_halo_color = color; } + + void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); } + void setShadowColor(const Color& color) { m_shadow_color = color; } + void setShadowOffX(int offx) { m_shadow_offx = offx; } + void setShadowOffY(int offy) { m_shadow_offy = offy; } + /** @param text text to check size @param size length of text in bytes

@@ -103,28 +109,28 @@ */

void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y, bool rotate=true) const; - bool isAntialias() const { return m_antialias; } /// @return true if the font is rotated, else false bool isRotated() const { return m_rotated; } /// @return rotated angle float angle() const { return m_angle; } - bool shadow() const { return m_shadow; } - bool halo() const { return m_halo; } + bool hasShadow() const { return m_shadow; } + bool hasHalo() const { return m_halo; } private: - std::auto_ptr<FontImp> m_fontimp; ///< font implementation + FbTk::FontImp* m_fontimp; ///< font implementation std::string m_fontstr; ///< font name - static bool m_multibyte; ///< if the fontimp should be a multibyte font - static bool m_utf8mode; ///< should the font use utf8 font imp - bool m_antialias; ///< is font antialias + + static bool s_multibyte; ///< if the fontimp should be a multibyte font + static bool s_utf8mode; ///< should the font use utf8 font imp + bool m_rotated; ///< wheter we're rotated or not float m_angle; ///< rotation angle bool m_shadow; ///< shadow text - std::string m_shadow_color; ///< shadow color + Color m_shadow_color; ///< shadow color int m_shadow_offx; ///< offset y for shadow int m_shadow_offy; ///< offset x for shadow bool m_halo; ///< halo text - std::string m_halo_color; ///< halo color + Color m_halo_color; ///< halo color #ifdef HAVE_ICONV iconv_t m_iconv; #else
M src/FbTk/MenuTheme.ccsrc/FbTk/MenuTheme.cc

@@ -171,19 +171,4 @@ void ThemeItem<MenuTheme::BulletType>::load(const std::string *name, const std::string *altname) {

// do nothing, we don't have anything extra to load } -template <> -void ThemeItem<unsigned int>::setDefaultValue() { - m_value = 0; -} - -template <> -void ThemeItem<unsigned int>::setFromString(const char *str) { - sscanf(str, "%d", &m_value); -} - -template <> -void ThemeItem<unsigned int>::load(const std::string *name, const std::string *altname) { -} - - }; // end namespace FbTk
M src/FbTk/Texture.ccsrc/FbTk/Texture.cc

@@ -57,9 +57,7 @@ setType(Texture::PARENTRELATIVE);

} else { setType(Texture::NONE); - if (strstr(ts, "solid")) - addType(Texture::SOLID); - else if (strstr(ts, "gradient")) { + if (strstr(ts, "gradient")) { addType(Texture::GRADIENT); if (strstr(ts, "crossdiagonal")) addType(Texture::CROSSDIAGONAL);

@@ -79,17 +77,15 @@ else if (strstr(ts, "vertical"))

addType(Texture::VERTICAL); else addType(Texture::DIAGONAL); - } else + } else // default is "solid", according to ThemeItems.cc addType(Texture::SOLID); if (strstr(ts, "raised")) addType(Texture::RAISED); else if (strstr(ts, "sunken")) addType(Texture::SUNKEN); - else if (strstr(ts, "flat")) - addType(Texture::FLAT); - else - addType(Texture::RAISED); + else // default us "flat", according to ThemeItems.cc + addType(Texture::FLAT); if (! (type() & Texture::FLAT)) if (strstr(ts, "bevel2"))
M src/FbTk/ThemeItems.ccsrc/FbTk/ThemeItems.cc

@@ -26,6 +26,10 @@

#ifndef THEMEITEMS_HH #define THEMEITEMS_HH +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + #include "Theme.hh" #include "Color.hh" #include "Texture.hh"

@@ -98,9 +102,40 @@ *(*this) = false;

} template <> +void ThemeItem<unsigned int>::setDefaultValue() { + m_value = 0; +} + +template <> +void ThemeItem<unsigned int>::setFromString(const char *str) { + sscanf(str, "%d", &m_value); +} + +template <> +void ThemeItem<unsigned int>::load(const std::string *name, const std::string *altname) { +} + + void ThemeItem<Font>::setDefaultValue() { if (!m_value.load("fixed")) { cerr<<"ThemeItem<Font>: Warning! Failed to load default value 'fixed'"<<endl; + } else { + string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect")); + if (effect == "halo") { + m_value.setHalo(true); + FbTk::Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), + theme().screenNum()); + m_value.setHaloColor(halo_color); + + } else if (effect == "shadow" ) { + FbTk::Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.x", altName()+".Shadow.X").c_str(), + theme().screenNum()); + + m_value.setShadow(true); + m_value.setShadowColor(shadow_color); + m_value.setShadowOffX(atoi(ThemeManager::instance().resourceValue(name()+".shadow.x", altName()+".Shadow.X").c_str())); + m_value.setShadowOffY(atoi(ThemeManager::instance().resourceValue(name()+".shadow.y", altName()+".Shadow.Y").c_str())); + } } }

@@ -110,19 +145,30 @@

if (str == 0 || m_value.load(str) == false) { if (ThemeManager::instance().verbose()) { cerr<<"Theme: Error loading font "<< - ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< - - (m_value.isAntialias() ? "antialias" : "")<< - (m_value.utf8() ? " utf8" : "")<< - - ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< + ((m_value.utf8()) ? "(utf8)" : "")<< "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl; cerr<<"Theme: Setting default value"<<endl; } setDefaultValue(); - } + } else { + string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect")); + if (effect == "halo") { + m_value.setHalo(true); + FbTk::Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), + theme().screenNum()); + m_value.setHaloColor(halo_color); + } else if (effect == "shadow" ) { + FbTk::Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.x", altName()+".Shadow.X").c_str(), + theme().screenNum()); + + m_value.setShadow(true); + m_value.setShadowColor(shadow_color); + m_value.setShadowOffX(atoi(ThemeManager::instance().resourceValue(name()+".shadow.x", altName()+".Shadow.X").c_str())); + m_value.setShadowOffY(atoi(ThemeManager::instance().resourceValue(name()+".shadow.y", altName()+".Shadow.Y").c_str())); + } + } } // do nothing
M src/FbTk/XftFontImp.ccsrc/FbTk/XftFontImp.cc

@@ -33,7 +33,6 @@ namespace FbTk {

XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), m_utf8mode(utf8) { - if (name != 0) load(name); }

@@ -47,13 +46,14 @@ bool XftFontImp::load(const std::string &name) {

//Note: assumes screen 0 for now, changes on draw if needed Display *disp = App::instance()->display(); - XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); - if (newxftfont == 0) { // failed to open font, lets test with XLFD - newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); + XftFont *newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); + if (newxftfont == 0) { + newxftfont = XftFontOpenName(disp, 0, name.c_str()); if (newxftfont == 0) return false; } + // destroy old font and set new if (m_xftfont != 0) XftFontClose(disp, m_xftfont);
M src/FbTk/XftFontImp.hhsrc/FbTk/XftFontImp.hh

@@ -24,9 +24,8 @@

#ifndef FBTK_XFTFONTIMP_HH #define FBTK_XFTFONTIMP_HH +#include <X11/Xft/Xft.h> #include "FontImp.hh" - -#include <X11/Xft/Xft.h> namespace FbTk {
M src/IconbarTheme.ccsrc/IconbarTheme.cc

@@ -53,11 +53,6 @@ m_focused_text.update();

m_unfocused_text.update(); } -void IconbarTheme::setAntialias(bool value) { - m_focused_text.setAntialias(value); - m_unfocused_text.setAntialias(value); -} - // fallback resources bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { using namespace FbTk;
M src/Screen.ccsrc/Screen.cc

@@ -310,14 +310,6 @@ m_menutheme->setDelayClose(*resource.menu_delay_close);

imageControl().setDither(*resource.image_dither); - // setup windowtheme for antialias - // before we load the theme - - winFrameTheme().font().setAntialias(*resource.antialias); - menuTheme().titleFont().setAntialias(*resource.antialias); - menuTheme().frameFont().setAntialias(*resource.antialias); - - winFrameTheme().reconfigSig().attach(this);// for geom window

@@ -343,7 +335,8 @@ //!! TODO: we shouldn't do this more than once, but since slit handles their

// own resources we must do this. fluxbox->load_rc(*this); - m_configmenu.reset(createMenu(_FBTEXT(Menu, Configuration, "Configuration", "Title of configuration menu"))); + m_configmenu.reset(createMenu(_FBTEXT(Menu, Configuration, + "Configuration", "Title of configuration menu"))); setupConfigmenu(*m_configmenu.get()); m_configmenu->setInternalMenu();

@@ -673,11 +666,6 @@

m_menutheme->setDelayOpen(*resource.menu_delay); m_menutheme->setDelayClose(*resource.menu_delay_close); - // setup windowtheme, toolbartheme for antialias - winFrameTheme().font().setAntialias(*resource.antialias); - m_menutheme->titleFont().setAntialias(*resource.antialias); - m_menutheme->frameFont().setAntialias(*resource.antialias); - renderGeomWindow(); renderPosWindow();

@@ -847,13 +835,6 @@ // the client could be on icon menu so we update it

//!! TODO: check this with the new icon menu // updateIconMenu(); -} - -void BScreen::setAntialias(bool value) { - if (*resource.antialias == value) - return; - resource.antialias = value; - reconfigure(); } int BScreen::addWorkspace() {

@@ -1812,12 +1793,6 @@ *resource.decorate_transient, saverc_cmd);

_BOOLITEM(Configmenu, ClickRaises, "Click Raises", "Click Raises", *resource.click_raises, saverc_cmd); -#ifdef USE_XFT - // setup antialias cmd to reload style and save resource on toggle - _BOOLITEM(Configmenu, AntiAlias, - "AntiAlias", "Use Anti-aliased fonts", - *resource.antialias, save_and_reconfigure); -#endif // USE_XFT #ifdef HAVE_XRENDER if (FbTk::Transparent::haveRender() ||
M src/Screen.hhsrc/Screen.hh

@@ -218,8 +218,6 @@ inline void saveWorkspaces(int w) { *resource.workspaces = w; }

void saveMenu(FbTk::Menu &menu) { m_rootmenu_list.push_back(&menu); } - void setAntialias(bool value); - inline FbWinFrameTheme &winFrameTheme() { return *m_windowtheme.get(); } inline const FbWinFrameTheme &winFrameTheme() const { return *m_windowtheme.get(); } inline MenuTheme &menuTheme() { return *m_menutheme.get(); }
M src/TextTheme.ccsrc/TextTheme.cc

@@ -34,6 +34,9 @@ m_font(theme, name + ".font", altname + ".Font"),

m_text_color(theme, name + ".textColor", altname + ".TextColor"), m_justify(theme, name + ".justify", altname + ".Justify"), m_text_gc(RootWindow(FbTk::App::instance()->display(), theme.screenNum())) { + *m_justify = FbTk::LEFT; + // set default values + m_text_color->setFromString("white", theme.screenNum()); update(); }

@@ -45,9 +48,3 @@

void TextTheme::update() { m_text_gc.setForeground(*m_text_color); } - - -void TextTheme::setAntialias(bool value) { - font().setAntialias(value); - FbTk::ThemeManager::instance().loadItem(m_font); -}
M src/TextTheme.hhsrc/TextTheme.hh

@@ -38,8 +38,6 @@ virtual ~TextTheme();

void update(); - void setAntialias(bool value); - FbTk::Font &font() { return *m_font; } const FbTk::Font &font() const { return *m_font; } const FbTk::Color &textColor() const { return *m_text_color; }
M src/ToolFactory.ccsrc/ToolFactory.cc

@@ -152,13 +152,9 @@ return item;

} void ToolFactory::updateThemes() { - m_clock_theme.setAntialias(screen().antialias()); m_clock_theme.reconfigTheme(); - m_iconbar_theme.setAntialias(screen().antialias()); m_iconbar_theme.reconfigTheme(); - m_button_theme->setAntialias(screen().antialias()); m_button_theme->reconfigTheme(); - m_workspace_theme->setAntialias(screen().antialias()); m_workspace_theme->reconfigTheme(); }
M src/tests/menutest.ccsrc/tests/menutest.cc

@@ -73,8 +73,8 @@ m_image_ctrl(DefaultScreen(display())),

m_menu_theme(DefaultScreen(display())), m_menu(m_menu_theme, m_image_ctrl) { - m_menu_theme.frameFont().setAntialias(true); - m_menu_theme.titleFont().setAntialias(true); + //m_menu_theme.frameFont().setAntialias(true); + //m_menu_theme.titleFont().setAntialias(true); cerr<<"Loading menu: "<<menufile<<endl; FbMenuParser parser(menufile);
M src/tests/testFont.ccsrc/tests/testFont.cc

@@ -1,4 +1,3 @@

-// testFont.cc for fbtk test suite // Copyright (c) 2002 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a

@@ -56,12 +55,13 @@ char keychar[1];

XLookupString(&ke, keychar, 1, &ks, 0); if (ks == XK_Escape) end(); + /* else { // toggle antialias m_font.setAntialias(!m_font.isAntialias()); cerr<<boolalpha; cerr<<"antialias: "<<m_font.isAntialias()<<endl; redraw(); - } + } */ } void exposeEvent(XExposeEvent &event) {

@@ -86,7 +86,7 @@ wingc.setForeground(FbTk::Color("red", m_win.screenNumber()));

m_win.drawLine(wingc.gc(), x, y, x + text_w, y); wingc.setForeground(FbTk::Color(m_foreground.c_str(), m_win.screenNumber())); - cerr<<"text width: "<<m_font.textWidth(m_text.c_str(), m_text.size())<<endl; + //cerr<<"text width: "<<m_font.textWidth(m_text.c_str(), m_text.size())<<endl; m_font.drawText(m_win, 0, wingc.gc(), m_text.c_str(), m_text.size(),

@@ -105,9 +105,10 @@ string m_text;

}; int main(int argc, char **argv) { - bool antialias = false; + //bool antialias = false; bool rotate = false; - string fontname("fixed"); + bool xft = false; + string fontname(""); string displayname(""); string background("black"); string foreground("white");

@@ -115,8 +116,8 @@ string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±");

for (int a=1; a<argc; ++a) { if (strcmp("-font", argv[a])==0 && a + 1 < argc) { fontname = argv[++a]; - } else if (strcmp("-antialias", argv[a]) == 0) { - antialias = true; + } else if (strcmp("-xft", argv[a])==0) { + xft = true; } else if (strcmp("-display", argv[a]) == 0 && a + 1 < argc) { displayname = argv[++a]; } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) {

@@ -130,7 +131,7 @@ foreground = argv[++a];

} else if (strcmp("-h", argv[a]) == 0) { cerr<<"Arguments: "<<endl; cerr<<"-font <fontname>"<<endl; - cerr<<"-antialias"<<endl; + // cerr<<"-antialias"<<endl; cerr<<"-display <display>"<<endl; cerr<<"-text <text>"<<endl; cerr<<"-rotate"<<endl;

@@ -144,7 +145,7 @@ }

App app(displayname.c_str(), foreground, background); - app.font().setAntialias(antialias); + //app.font().setAntialias(antialias); if (!app.font().load(fontname.c_str())) cerr<<"Failed to load: "<<fontname<<endl; cerr<<"Setting text: "<<text<<endl;
M util/fbrun/FbRun.hhutil/fbrun/FbRun.hh

@@ -48,7 +48,7 @@

/// load and reconfigure for new font bool loadFont(const std::string &fontname); void setForegroundColor(const FbTk::Color &color); - void setAntialias(bool val) { m_font.setAntialias(val); } + void setAntialias(bool val) { /*m_font.setAntialias(val);*/ } const FbTk::Font &font() const { return m_font; } /// execute command and exit void run(const std::string &execstring);
M util/fbrun/main.ccutil/fbrun/main.cc

@@ -119,7 +119,7 @@

FbTk::App application(display_name.c_str()); FbRun fbrun; - fbrun.setAntialias(antialias); + //fbrun.setAntialias(antialias); if (fontname.size() != 0) { if (!fbrun.loadFont(fontname.c_str())) {

@@ -140,8 +140,8 @@ if (set_height)

fbrun.resize(fbrun.width(), height); if (set_width) fbrun.resize(width, fbrun.height()); - if (antialias) - fbrun.setAntialias(antialias); + //if (antialias) + // fbrun.setAntialias(antialias); // expand and load command history string expanded_filename = FbTk::StringUtil::expandFilename(history_file); if (!fbrun.loadHistory(expanded_filename.c_str()))