fix a issue with fonts coming up blank
This commit is contained in:
parent
11f8d9c21f
commit
c4c67dafeb
3 changed files with 32 additions and 8 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue