aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XFontImp.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-08 18:17:21 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-08 18:17:21 (GMT)
commit690d926ac444243611cd875fb84fabb4e6db2cf2 (patch)
treec8ef84056b295071f9a9207ffea5393c6cf4ad4d /src/FbTk/XFontImp.cc
parent1e8fe2bc14856fa16508686a28a85e72cb0e422c (diff)
downloadfluxbox_pavel-690d926ac444243611cd875fb84fabb4e6db2cf2.zip
fluxbox_pavel-690d926ac444243611cd875fb84fabb4e6db2cf2.tar.bz2
introduced FbTk::BidiString
a 'BidiString' holds both the logical content and the visual reordered version of the content of a string. this helps to reduce the number of calls to reorder the string before drawing it (as introduced in the patch from Ken Bloom) and to be more consistent in menus and textboxes (drawing cursors and underlining text).
Diffstat (limited to 'src/FbTk/XFontImp.cc')
-rw-r--r--src/FbTk/XFontImp.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc
index 257a2a0..fa88593 100644
--- a/src/FbTk/XFontImp.cc
+++ b/src/FbTk/XFontImp.cc
@@ -97,8 +97,9 @@ bool XFontImp::load(const string &fontname) {
97 return true; 97 return true;
98} 98}
99 99
100void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) { 100void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char* text, size_t len, int x, int y, FbTk::Orientation orient) {
101 if (m_fontstruct == 0) 101
102 if (!text || !*text || m_fontstruct == 0)
102 return; 103 return;
103 104
104 // use roated font functions? 105 // use roated font functions?
@@ -107,21 +108,18 @@ void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &
107 return; 108 return;
108 } 109 }
109 110
110 string localestr = text; 111 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len));
111 localestr.erase(len, string::npos);
112 localestr = FbStringUtil::FbStrToLocale(localestr);
113 112
114 XSetFont(w.display(), gc, m_fontstruct->fid); 113 XSetFont(w.display(), gc, m_fontstruct->fid);
115 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());
116} 115}
117 116
118unsigned int XFontImp::textWidth(const FbString &text, unsigned int size) const { 117unsigned int XFontImp::textWidth(const char* text, unsigned int size) const {
119 if (text.empty() || m_fontstruct == 0) 118
119 if (!text || !*text || m_fontstruct == 0)
120 return 0; 120 return 0;
121 121
122 string localestr = text; 122 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, size));
123 localestr.erase(size, string::npos);
124 localestr = FbStringUtil::FbStrToLocale(localestr);
125 123
126 return XTextWidth(m_fontstruct, localestr.data(), localestr.size()); 124 return XTextWidth(m_fontstruct, localestr.data(), localestr.size());
127} 125}