From c4c67dafeb9165f394c1bae25604f97921a8ae7a Mon Sep 17 00:00:00 2001 From: rathnor Date: Sat, 28 Aug 2004 18:10:19 +0000 Subject: fix a issue with fonts coming up blank --- ChangeLog | 2 ++ src/FbTk/Font.cc | 6 +++--- src/FbTk/XmbFontImp.cc | 32 +++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73c8280..36432d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.10: *04/08/28: + * Fix some blank fonts problem for i18n (I think) (Simon) + FbTk/Font.cc FbTk/XmbFontImp.cc * Fix menu render bug with previously highlighted items (Simon) FbTk/Menu.cc *04/08/27: diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 7cacbd5..40da222 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.cc,v 1.12 2004/08/25 10:03:09 akir Exp $ +//$Id: Font.cc,v 1.13 2004/08/28 18:10:19 rathnor Exp $ #include "StringUtil.hh" @@ -356,7 +356,7 @@ bool Font::load(const std::string &name) { } unsigned int Font::textWidth(const char * const text, unsigned int size) const { - if (isAntialias() && m_iconv != (iconv_t)(-1)) { + if (m_iconv != (iconv_t)(-1)) { char* rtext = recode(m_iconv, text, size); if (rtext != 0) size = strlen(rtext); @@ -392,7 +392,7 @@ void Font::drawText(Drawable w, int screen, GC gc, // so we don't end up in a loop with m_shadow static bool first_run = true; - if (isAntialias() && m_iconv != (iconv_t)(-1) && first_run) { + if (m_iconv != (iconv_t)(-1) && first_run) { rtext = recode(m_iconv, text, len); if (rtext != 0) { len = strlen(rtext); diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc index d06f05d..b6f8941 100644 --- a/src/FbTk/XmbFontImp.cc +++ b/src/FbTk/XmbFontImp.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XmbFontImp.cc,v 1.8 2004/08/10 11:57:35 fluxgen Exp $ +// $Id: XmbFontImp.cc,v 1.9 2004/08/28 18:10:19 rathnor Exp $ #include "XmbFontImp.hh" @@ -116,17 +116,31 @@ const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...) { return 0; } -XFontSet createFontSet(const char *fontname) { +XFontSet createFontSet(const char *fontname, bool utf8mode) { Display *display = FbTk::App::instance()->display(); XFontSet fs; const int FONT_ELEMENT_SIZE=50; char **missing, *def = "-"; int nmissing, pixel_size = 0, buf_size = 0; char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; + char * orig_locale = ""; +#ifdef HAVE_SETLOCALE + if (utf8mode) { + orig_locale = setlocale(LC_CTYPE, NULL); + setlocale(LC_CTYPE, "UTF-8"); + } +#endif // HAVE_SETLOCALE fs = XCreateFontSet(display, fontname, &missing, &nmissing, &def); - if (fs && (! nmissing)) return fs; + + if (fs && (! nmissing)) { +#ifdef HAVE_SETLOCALE + if (utf8mode) + setlocale(LC_CTYPE, orig_locale); +#endif // HAVE_SETLOCALE + return fs; + } #ifdef HAVE_SETLOCALE if (! fs) { @@ -135,7 +149,7 @@ XFontSet createFontSet(const char *fontname) { setlocale(LC_CTYPE, "C"); fs = XCreateFontSet(display, fontname, &missing, &nmissing, &def); - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, orig_locale); } #endif // HAVE_SETLOCALE @@ -179,6 +193,11 @@ XFontSet createFontSet(const char *fontname) { &missing, &nmissing, &def); delete [] pattern2; +#ifdef HAVE_SETLOCALE + if (utf8mode) + setlocale(LC_CTYPE, orig_locale); +#endif // HAVE_SETLOCALE + return fs; } @@ -198,11 +217,14 @@ XmbFontImp::~XmbFontImp() { bool XmbFontImp::load(const std::string &fontname) { if (fontname.size() == 0) return false; - XFontSet set = createFontSet(fontname.c_str()); + + XFontSet set = createFontSet(fontname.c_str(), m_utf8mode); if (set == 0) return false; + if (m_fontset != 0) XFreeFontSet(App::instance()->display(), m_fontset); + m_fontset = set; m_setextents = XExtentsOfFontSet(m_fontset); -- cgit v0.11.2