fix a issue with fonts coming up blank
rathnor rathnor
3 files changed,
32 insertions(+),
8 deletions(-)
M
src/FbTk/Font.cc
→
src/FbTk/Font.cc
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ return m_fontimp->load(fname.c_str());
} 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 @@
// 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);
M
src/FbTk/XmbFontImp.cc
→
src/FbTk/XmbFontImp.cc
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ strncpy(buf, "*", 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 @@
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 @@ fs = XCreateFontSet(display, 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 @@
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);