aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-08-28 18:10:19 (GMT)
committerrathnor <rathnor>2004-08-28 18:10:19 (GMT)
commitc4c67dafeb9165f394c1bae25604f97921a8ae7a (patch)
treef4489d70010c6de1cc141ea52bd7c9ccf603fb0a /src/FbTk
parent11f8d9c21f6da5abf01d942589914b26e04c20d9 (diff)
downloadfluxbox_paul-c4c67dafeb9165f394c1bae25604f97921a8ae7a.zip
fluxbox_paul-c4c67dafeb9165f394c1bae25604f97921a8ae7a.tar.bz2
fix a issue with fonts coming up blank
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Font.cc6
-rw-r--r--src/FbTk/XmbFontImp.cc32
2 files changed, 30 insertions, 8 deletions
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 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Font.cc,v 1.12 2004/08/25 10:03:09 akir Exp $ 22//$Id: Font.cc,v 1.13 2004/08/28 18:10:19 rathnor Exp $
23 23
24 24
25#include "StringUtil.hh" 25#include "StringUtil.hh"
@@ -356,7 +356,7 @@ bool Font::load(const std::string &name) {
356} 356}
357 357
358unsigned int Font::textWidth(const char * const text, unsigned int size) const { 358unsigned int Font::textWidth(const char * const text, unsigned int size) const {
359 if (isAntialias() && m_iconv != (iconv_t)(-1)) { 359 if (m_iconv != (iconv_t)(-1)) {
360 char* rtext = recode(m_iconv, text, size); 360 char* rtext = recode(m_iconv, text, size);
361 if (rtext != 0) 361 if (rtext != 0)
362 size = strlen(rtext); 362 size = strlen(rtext);
@@ -392,7 +392,7 @@ void Font::drawText(Drawable w, int screen, GC gc,
392 // so we don't end up in a loop with m_shadow 392 // so we don't end up in a loop with m_shadow
393 static bool first_run = true; 393 static bool first_run = true;
394 394
395 if (isAntialias() && m_iconv != (iconv_t)(-1) && first_run) { 395 if (m_iconv != (iconv_t)(-1) && first_run) {
396 rtext = recode(m_iconv, text, len); 396 rtext = recode(m_iconv, text, len);
397 if (rtext != 0) { 397 if (rtext != 0) {
398 len = strlen(rtext); 398 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 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: XmbFontImp.cc,v 1.8 2004/08/10 11:57:35 fluxgen Exp $ 22// $Id: XmbFontImp.cc,v 1.9 2004/08/28 18:10:19 rathnor Exp $
23 23
24#include "XmbFontImp.hh" 24#include "XmbFontImp.hh"
25 25
@@ -116,17 +116,31 @@ const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...) {
116 return 0; 116 return 0;
117} 117}
118 118
119XFontSet createFontSet(const char *fontname) { 119XFontSet createFontSet(const char *fontname, bool utf8mode) {
120 Display *display = FbTk::App::instance()->display(); 120 Display *display = FbTk::App::instance()->display();
121 XFontSet fs; 121 XFontSet fs;
122 const int FONT_ELEMENT_SIZE=50; 122 const int FONT_ELEMENT_SIZE=50;
123 char **missing, *def = "-"; 123 char **missing, *def = "-";
124 int nmissing, pixel_size = 0, buf_size = 0; 124 int nmissing, pixel_size = 0, buf_size = 0;
125 char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; 125 char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE];
126 char * orig_locale = "";
126 127
128#ifdef HAVE_SETLOCALE
129 if (utf8mode) {
130 orig_locale = setlocale(LC_CTYPE, NULL);
131 setlocale(LC_CTYPE, "UTF-8");
132 }
133#endif // HAVE_SETLOCALE
127 fs = XCreateFontSet(display, 134 fs = XCreateFontSet(display,
128 fontname, &missing, &nmissing, &def); 135 fontname, &missing, &nmissing, &def);
129 if (fs && (! nmissing)) return fs; 136
137 if (fs && (! nmissing)) {
138#ifdef HAVE_SETLOCALE
139 if (utf8mode)
140 setlocale(LC_CTYPE, orig_locale);
141#endif // HAVE_SETLOCALE
142 return fs;
143 }
130 144
131#ifdef HAVE_SETLOCALE 145#ifdef HAVE_SETLOCALE
132 if (! fs) { 146 if (! fs) {
@@ -135,7 +149,7 @@ XFontSet createFontSet(const char *fontname) {
135 setlocale(LC_CTYPE, "C"); 149 setlocale(LC_CTYPE, "C");
136 fs = XCreateFontSet(display, fontname, 150 fs = XCreateFontSet(display, fontname,
137 &missing, &nmissing, &def); 151 &missing, &nmissing, &def);
138 setlocale(LC_CTYPE, ""); 152 setlocale(LC_CTYPE, orig_locale);
139 } 153 }
140#endif // HAVE_SETLOCALE 154#endif // HAVE_SETLOCALE
141 155
@@ -179,6 +193,11 @@ XFontSet createFontSet(const char *fontname) {
179 &missing, &nmissing, &def); 193 &missing, &nmissing, &def);
180 delete [] pattern2; 194 delete [] pattern2;
181 195
196#ifdef HAVE_SETLOCALE
197 if (utf8mode)
198 setlocale(LC_CTYPE, orig_locale);
199#endif // HAVE_SETLOCALE
200
182 return fs; 201 return fs;
183} 202}
184 203
@@ -198,11 +217,14 @@ XmbFontImp::~XmbFontImp() {
198bool XmbFontImp::load(const std::string &fontname) { 217bool XmbFontImp::load(const std::string &fontname) {
199 if (fontname.size() == 0) 218 if (fontname.size() == 0)
200 return false; 219 return false;
201 XFontSet set = createFontSet(fontname.c_str()); 220
221 XFontSet set = createFontSet(fontname.c_str(), m_utf8mode);
202 if (set == 0) 222 if (set == 0)
203 return false; 223 return false;
224
204 if (m_fontset != 0) 225 if (m_fontset != 0)
205 XFreeFontSet(App::instance()->display(), m_fontset); 226 XFreeFontSet(App::instance()->display(), m_fontset);
227
206 m_fontset = set; 228 m_fontset = set;
207 m_setextents = XExtentsOfFontSet(m_fontset); 229 m_setextents = XExtentsOfFontSet(m_fontset);
208 230