diff options
author | mathias <mathias> | 2004-11-19 12:00:20 (GMT) |
---|---|---|
committer | mathias <mathias> | 2004-11-19 12:00:20 (GMT) |
commit | 66a3fc1c4dfa2cb68e650257e0bd10f2906c0d39 (patch) | |
tree | 76f6052a4f5e52288107a78d4307fd719c20b5f6 /src/FbTk/Font.cc | |
parent | 993c17cf2efd3caba5241276c268909197dd3681 (diff) | |
download | fluxbox-66a3fc1c4dfa2cb68e650257e0bd10f2906c0d39.zip fluxbox-66a3fc1c4dfa2cb68e650257e0bd10f2906c0d39.tar.bz2 |
fixes fontsituations when text disappears in non-antialias mode
primary problem was to use utf8 when in fact the FontSet wasnt
utf8.
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r-- | src/FbTk/Font.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 3bacbce..e2e3dec 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc | |||
@@ -133,7 +133,7 @@ char* recode(iconv_t cd, | |||
133 | // 2) An incomplete multibyte sequence | 133 | // 2) An incomplete multibyte sequence |
134 | // 3) The output buffer has no more room for the next converted character. | 134 | // 3) The output buffer has no more room for the next converted character. |
135 | // So we the delete new message and return original message | 135 | // So we the delete new message and return original message |
136 | delete new_msg_ptr; | 136 | delete[] new_msg_ptr; |
137 | free(orig_msg_ptr); | 137 | free(orig_msg_ptr); |
138 | return 0; | 138 | return 0; |
139 | } | 139 | } |
@@ -142,7 +142,7 @@ char* recode(iconv_t cd, | |||
142 | *new_msg = '\0'; | 142 | *new_msg = '\0'; |
143 | 143 | ||
144 | if(inbytesleft != 0) { | 144 | if(inbytesleft != 0) { |
145 | delete new_msg_ptr; | 145 | delete[] new_msg_ptr; |
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
@@ -231,7 +231,7 @@ bool Font::m_utf8mode = false; | |||
231 | 231 | ||
232 | // some initialisation for using fonts | 232 | // some initialisation for using fonts |
233 | void fontInit() { | 233 | void fontInit() { |
234 | setlocale(LC_CTYPE, ""); | 234 | setlocale(LC_CTYPE, ""); |
235 | } | 235 | } |
236 | 236 | ||
237 | Font::Font(const char *name, bool antialias): | 237 | Font::Font(const char *name, bool antialias): |
@@ -239,13 +239,13 @@ Font::Font(const char *name, bool antialias): | |||
239 | m_antialias(false), m_rotated(false), | 239 | m_antialias(false), m_rotated(false), |
240 | m_shadow(false), m_shadow_color("#000000"), | 240 | m_shadow(false), m_shadow_color("#000000"), |
241 | m_shadow_offx(1), m_shadow_offy(1), | 241 | m_shadow_offx(1), m_shadow_offy(1), |
242 | m_halo(false), m_halo_color("#ffffff") { | 242 | m_halo(false), m_halo_color("#ffffff"), |
243 | |||
244 | #ifdef HAVE_ICONV | 243 | #ifdef HAVE_ICONV |
245 | m_iconv = (iconv_t)(-1); | 244 | m_iconv((iconv_t)(-1)) |
246 | #else | 245 | #else |
247 | m_iconv = -1; | 246 | m_iconv(-1) |
248 | #endif // HAVE_ICONV | 247 | #endif // HAVE_ICONV |
248 | { | ||
249 | 249 | ||
250 | // MB_CUR_MAX returns the size of a char in the current locale | 250 | // MB_CUR_MAX returns the size of a char in the current locale |
251 | if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte | 251 | if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte |
@@ -295,7 +295,6 @@ Font::Font(const char *name, bool antialias): | |||
295 | #ifdef USE_XFT | 295 | #ifdef USE_XFT |
296 | if (antialias) { | 296 | if (antialias) { |
297 | m_fontimp.reset(new XftFontImp(0, m_utf8mode)); | 297 | m_fontimp.reset(new XftFontImp(0, m_utf8mode)); |
298 | m_antialias = true; | ||
299 | } | 298 | } |
300 | #endif //USE_XFT | 299 | #endif //USE_XFT |
301 | // if we didn't create a Xft font then create basic font | 300 | // if we didn't create a Xft font then create basic font |
@@ -341,9 +340,9 @@ void Font::setAntialias(bool flag) { | |||
341 | if (!m_fontimp->load("fixed")) {// if that failes too, output warning | 340 | if (!m_fontimp->load("fixed")) {// if that failes too, output warning |
342 | _FB_USES_NLS; | 341 | _FB_USES_NLS; |
343 | cerr<<_FBTKTEXT(Error, CantFallbackFont, "Warning: can't load fallback font", "Attempt to load the last-resort default font failed")<<" 'fixed'."<<endl; | 342 | cerr<<_FBTKTEXT(Error, CantFallbackFont, "Warning: can't load fallback font", "Attempt to load the last-resort default font failed")<<" 'fixed'."<<endl; |
344 | } | 343 | } |
345 | } | 344 | } |
346 | 345 | ||
347 | m_antialias = flag; | 346 | m_antialias = flag; |
348 | } | 347 | } |
349 | 348 | ||
@@ -400,13 +399,13 @@ bool Font::load(const std::string &name) { | |||
400 | 399 | ||
401 | unsigned int Font::textWidth(const char * const text, unsigned int size) const { | 400 | unsigned int Font::textWidth(const char * const text, unsigned int size) const { |
402 | #ifdef HAVE_ICONV | 401 | #ifdef HAVE_ICONV |
403 | if (m_iconv != (iconv_t)(-1)) { | 402 | if (m_fontimp->utf8() && m_iconv != (iconv_t)(-1)) { |
404 | char* rtext = recode(m_iconv, text, size); | 403 | char* rtext = recode(m_iconv, text, size); |
405 | if (rtext != 0) | 404 | if (rtext != 0) |
406 | size = strlen(rtext); | 405 | size = strlen(rtext); |
407 | unsigned int r = m_fontimp->textWidth(rtext ? rtext : text, size); | 406 | unsigned int r = m_fontimp->textWidth(rtext ? rtext : text, size); |
408 | if (rtext != 0) | 407 | if (rtext != 0) |
409 | delete rtext; | 408 | delete[] rtext; |
410 | return r; | 409 | return r; |
411 | } | 410 | } |
412 | #endif // HAVE_ICONV | 411 | #endif // HAVE_ICONV |
@@ -437,7 +436,7 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc, | |||
437 | static bool first_run = true; | 436 | static bool first_run = true; |
438 | 437 | ||
439 | #ifdef HAVE_ICONV | 438 | #ifdef HAVE_ICONV |
440 | if (m_iconv != (iconv_t)(-1) && first_run) { | 439 | if (m_fontimp->utf8() && m_iconv != (iconv_t)(-1) && first_run) { |
441 | rtext = recode(m_iconv, text, len); | 440 | rtext = recode(m_iconv, text, len); |
442 | if (rtext != 0) { | 441 | if (rtext != 0) { |
443 | len = strlen(rtext); | 442 | len = strlen(rtext); |
@@ -490,7 +489,7 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc, | |||
490 | m_fontimp->drawText(w, screen, gc, real_text, len, x, y); | 489 | m_fontimp->drawText(w, screen, gc, real_text, len, x, y); |
491 | 490 | ||
492 | if (rtext != 0) | 491 | if (rtext != 0) |
493 | delete rtext; | 492 | delete[] rtext; |
494 | 493 | ||
495 | } | 494 | } |
496 | 495 | ||