summaryrefslogtreecommitdiff
path: root/src/FbTk/XmbFontImp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/XmbFontImp.cc')
-rw-r--r--src/FbTk/XmbFontImp.cc32
1 files changed, 27 insertions, 5 deletions
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