aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XFontImp.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-08 18:48:01 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-08 18:48:01 (GMT)
commit26c1cd0ceeb289abdf9ddfecdc699a27db8b0339 (patch)
tree8c71509d438106a831526645d418c889d1ce54ad /src/FbTk/XFontImp.cc
parent08bd29d0d83756944b35a312497fbadcde9d74fe (diff)
downloadfluxbox-26c1cd0ceeb289abdf9ddfecdc699a27db8b0339.zip
fluxbox-26c1cd0ceeb289abdf9ddfecdc699a27db8b0339.tar.bz2
code simplification
Diffstat (limited to 'src/FbTk/XFontImp.cc')
-rw-r--r--src/FbTk/XFontImp.cc23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc
index fa88593..73ae384 100644
--- a/src/FbTk/XFontImp.cc
+++ b/src/FbTk/XFontImp.cc
@@ -102,14 +102,14 @@ void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char* text
102 if (!text || !*text || m_fontstruct == 0) 102 if (!text || !*text || m_fontstruct == 0)
103 return; 103 return;
104 104
105 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, len));
106
105 // use roated font functions? 107 // use roated font functions?
106 if (orient != ROT0 && validOrientation(orient)) { 108 if (orient != ROT0 && validOrientation(orient)) {
107 drawRotText(w.drawable(), screen, gc, text, len, x, y, orient); 109 drawRotText(w.drawable(), screen, gc, localestr.c_str(), localestr.size(), x, y, orient);
108 return; 110 return;
109 } 111 }
110 112
111 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len));
112
113 XSetFont(w.display(), gc, m_fontstruct->fid); 113 XSetFont(w.display(), gc, m_fontstruct->fid);
114 XDrawString(w.display(), w.drawable(), gc, x, y, localestr.data(), localestr.size()); 114 XDrawString(w.display(), w.drawable(), gc, x, y, localestr.data(), localestr.size());
115} 115}
@@ -330,7 +330,10 @@ void XFontImp::freeRotFont(XRotFontStruct *rotfont) {
330 rotfont = 0; 330 rotfont = 0;
331} 331}
332 332
333void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { 333void XFontImp::drawRotText(Drawable w, int screen, GC gc, const char* text, size_t len, int x, int y, FbTk::Orientation orient) const {
334
335 if (!text || !*text || len<1)
336 return;
334 337
335 Display *dpy = App::instance()->display(); 338 Display *dpy = App::instance()->display();
336 static GC my_gc = 0; 339 static GC my_gc = 0;
@@ -338,27 +341,17 @@ void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text,
338 341
339 XRotFontStruct *rotfont = m_rotfonts[orient]; 342 XRotFontStruct *rotfont = m_rotfonts[orient];
340 343
341 if (text.empty() || len<1)
342 return;
343
344 if (my_gc == 0) 344 if (my_gc == 0)
345 my_gc = XCreateGC(dpy, w, 0, 0); 345 my_gc = XCreateGC(dpy, w, 0, 0);
346 346
347 XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc); 347 XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc);
348 348
349 // vertical or upside down 349 // vertical or upside down
350
351 XSetFillStyle(dpy, my_gc, FillStippled); 350 XSetFillStyle(dpy, my_gc, FillStippled);
352 string localestr = text;
353 localestr.erase(len, string::npos);
354 localestr = FbStringUtil::FbStrToLocale(localestr);
355 const char *ctext = localestr.data();
356 len = localestr.size();
357
358 351
359 // loop through each character in texting 352 // loop through each character in texting
360 for (size_t i = 0; i<len; i++) { 353 for (size_t i = 0; i<len; i++) {
361 ichar = ctext[i]-32; 354 ichar = text[i]-32;
362 355
363 // make sure it's a printing character 356 // make sure it's a printing character
364 if (ichar >= 0 && ichar<95) { 357 if (ichar >= 0 && ichar<95) {