all repos — fluxbox @ 66a3fc1c4dfa2cb68e650257e0bd10f2906c0d39

custom fork of the fluxbox windowmanager

fixes fontsituations when text disappears in non-antialias mode
primary problem was to use utf8 when in fact the FontSet wasnt
utf8.
mathias mathias
commit

66a3fc1c4dfa2cb68e650257e0bd10f2906c0d39

parent

993c17cf2efd3caba5241276c268909197dd3681

M src/FbTk/Font.ccsrc/FbTk/Font.cc

@@ -133,7 +133,7 @@ // 1) Invalid multibyte sequence is encountered in the input

// 2) An incomplete multibyte sequence // 3) The output buffer has no more room for the next converted character. // So we the delete new message and return original message - delete new_msg_ptr; + delete[] new_msg_ptr; free(orig_msg_ptr); return 0; }

@@ -142,7 +142,7 @@

*new_msg = '\0'; if(inbytesleft != 0) { - delete new_msg_ptr; + delete[] new_msg_ptr; return 0; }

@@ -231,7 +231,7 @@ bool Font::m_utf8mode = false;

// some initialisation for using fonts void fontInit() { - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, ""); } Font::Font(const char *name, bool antialias):

@@ -239,13 +239,13 @@ 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_halo(false), m_halo_color("#ffffff"), #ifdef HAVE_ICONV - m_iconv = (iconv_t)(-1); + m_iconv((iconv_t)(-1)) #else - m_iconv = -1; + 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

@@ -295,7 +295,6 @@ // antialias is prio 1

#ifdef USE_XFT if (antialias) { m_fontimp.reset(new XftFontImp(0, m_utf8mode)); - m_antialias = true; } #endif //USE_XFT // if we didn't create a Xft font then create basic font

@@ -341,9 +340,9 @@ 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; }

@@ -400,13 +399,13 @@ }

unsigned int Font::textWidth(const char * const text, unsigned int size) const { #ifdef HAVE_ICONV - if (m_iconv != (iconv_t)(-1)) { + if (m_fontimp->utf8() && m_iconv != (iconv_t)(-1)) { char* rtext = recode(m_iconv, text, size); if (rtext != 0) size = strlen(rtext); unsigned int r = m_fontimp->textWidth(rtext ? rtext : text, size); if (rtext != 0) - delete rtext; + delete[] rtext; return r; } #endif // HAVE_ICONV

@@ -437,7 +436,7 @@ // so we don't end up in a loop with m_shadow

static bool first_run = true; #ifdef HAVE_ICONV - if (m_iconv != (iconv_t)(-1) && first_run) { + if (m_fontimp->utf8() && m_iconv != (iconv_t)(-1) && first_run) { rtext = recode(m_iconv, text, len); if (rtext != 0) { len = strlen(rtext);

@@ -490,7 +489,7 @@ } else

m_fontimp->drawText(w, screen, gc, real_text, len, x, y); if (rtext != 0) - delete rtext; + delete[] rtext; }
M src/FbTk/FontImp.hhsrc/FbTk/FontImp.hh

@@ -50,6 +50,7 @@ virtual int descent() const = 0;

virtual unsigned int height() const = 0; virtual bool loaded() const = 0; virtual void rotate(float angle) { } // by default, no rotate support + virtual bool utf8() const { return false; }; protected: FontImp() { } };
M src/FbTk/XftFontImp.hhsrc/FbTk/XftFontImp.hh

@@ -42,6 +42,7 @@ unsigned int height() const;

int ascent() const { return m_xftfont ? m_xftfont->ascent : 0; } int descent() const { return m_xftfont ? m_xftfont->descent : 0; } bool loaded() const { return m_xftfont != 0; } + bool utf8() const { return m_utf8mode; } private: XftFont *m_xftfont; bool m_utf8mode;
M src/FbTk/XmbFontImp.ccsrc/FbTk/XmbFontImp.cc

@@ -110,7 +110,7 @@ strncpy(buf, "*", bufsiz);

return 0; } -XFontSet createFontSet(const char *fontname, bool utf8mode) { +XFontSet createFontSet(const char *fontname, bool& utf8mode) { Display *display = FbTk::App::instance()->display(); XFontSet fs; const int FONT_ELEMENT_SIZE=50;

@@ -192,13 +192,15 @@ if (utf8mode)

setlocale(LC_CTYPE, orig_locale.c_str()); #endif // HAVE_SETLOCALE + utf8mode = false; + return fs; } }; namespace FbTk { -XmbFontImp::XmbFontImp(const char *filename, bool utf8):m_fontset(0), m_setextents(0), m_utf8mode(utf8) { +XmbFontImp::XmbFontImp(const char *filename, bool utf8) : m_fontset(0), m_setextents(0), m_utf8mode(utf8) { if (filename != 0) load(filename); }

@@ -209,7 +211,7 @@ XFreeFontSet(App::instance()->display(), m_fontset);

} bool XmbFontImp::load(const std::string &fontname) { - if (fontname.size() == 0) + if (fontname.empty()) return false; XFontSet set = createFontSet(fontname.c_str(), m_utf8mode);
M src/FbTk/XmbFontImp.hhsrc/FbTk/XmbFontImp.hh

@@ -42,10 +42,11 @@ unsigned int height() const;

int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; } int descent() const { return m_setextents ? m_setextents->max_ink_extent.height + m_setextents->max_ink_extent.y : 0; } bool loaded() const { return m_fontset != 0; } + bool utf8() const { return m_utf8mode; } private: XFontSet m_fontset; XFontSetExtents *m_setextents; - const bool m_utf8mode; + bool m_utf8mode; }; } // end namespace FbTk