diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-09-08 18:17:21 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-09-08 18:17:21 (GMT) |
commit | 690d926ac444243611cd875fb84fabb4e6db2cf2 (patch) | |
tree | c8ef84056b295071f9a9207ffea5393c6cf4ad4d /src/FbTk/XmbFontImp.cc | |
parent | 1e8fe2bc14856fa16508686a28a85e72cb0e422c (diff) | |
download | fluxbox-690d926ac444243611cd875fb84fabb4e6db2cf2.zip fluxbox-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/XmbFontImp.cc')
-rw-r--r-- | src/FbTk/XmbFontImp.cc | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc index 3ce913d..7613a40 100644 --- a/src/FbTk/XmbFontImp.cc +++ b/src/FbTk/XmbFontImp.cc | |||
@@ -189,10 +189,10 @@ bool XmbFontImp::load(const string &fontname) { | |||
189 | return true; | 189 | return true; |
190 | } | 190 | } |
191 | 191 | ||
192 | void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbString &text, | 192 | void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const char* text, |
193 | size_t len, int x, int y, FbTk::Orientation orient) { | 193 | size_t len, int x, int y, FbTk::Orientation orient) { |
194 | 194 | ||
195 | if (m_fontset == 0) | 195 | if (!text || !*text || m_fontset == 0) |
196 | return; | 196 | return; |
197 | 197 | ||
198 | if (orient == ROT0) { | 198 | if (orient == ROT0) { |
@@ -200,13 +200,11 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS | |||
200 | if (m_utf8mode) { | 200 | if (m_utf8mode) { |
201 | Xutf8DrawString(d.display(), d.drawable(), m_fontset, | 201 | Xutf8DrawString(d.display(), d.drawable(), m_fontset, |
202 | main_gc, x, y, | 202 | main_gc, x, y, |
203 | text.data(), len); | 203 | text, len); |
204 | } else | 204 | } else |
205 | #endif //X_HAVE_UTF8_STRING | 205 | #endif //X_HAVE_UTF8_STRING |
206 | { | 206 | { |
207 | string localestr = text; | 207 | std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len)); |
208 | localestr.erase(len, string::npos); | ||
209 | localestr = FbStringUtil::FbStrToLocale(localestr); | ||
210 | XmbDrawString(d.display(), d.drawable(), m_fontset, | 208 | XmbDrawString(d.display(), d.drawable(), m_fontset, |
211 | main_gc, x, y, | 209 | main_gc, x, y, |
212 | localestr.data(), localestr.size()); | 210 | localestr.data(), localestr.size()); |
@@ -239,13 +237,11 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS | |||
239 | if (m_utf8mode) { | 237 | if (m_utf8mode) { |
240 | Xutf8DrawString(dpy, canvas.drawable(), m_fontset, | 238 | Xutf8DrawString(dpy, canvas.drawable(), m_fontset, |
241 | font_gc.gc(), xpos, ypos, | 239 | font_gc.gc(), xpos, ypos, |
242 | text.data(), len); | 240 | text, len); |
243 | } else | 241 | } else |
244 | #endif //X_HAVE_UTF8_STRING | 242 | #endif //X_HAVE_UTF8_STRING |
245 | { | 243 | { |
246 | string localestr = text; | 244 | std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len)); |
247 | localestr.erase(len, string::npos); | ||
248 | localestr = FbStringUtil::FbStrToLocale(localestr); | ||
249 | XmbDrawString(dpy, canvas.drawable(), m_fontset, | 245 | XmbDrawString(dpy, canvas.drawable(), m_fontset, |
250 | font_gc.gc(), xpos, ypos, | 246 | font_gc.gc(), xpos, ypos, |
251 | localestr.data(), localestr.size()); | 247 | localestr.data(), localestr.size()); |
@@ -277,25 +273,21 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS | |||
277 | 273 | ||
278 | } | 274 | } |
279 | 275 | ||
280 | unsigned int XmbFontImp::textWidth(const FbString &text, unsigned int len) const { | 276 | unsigned int XmbFontImp::textWidth(const char* text, unsigned int len) const { |
277 | |||
281 | if (m_fontset == 0) | 278 | if (m_fontset == 0) |
282 | return 0; | 279 | return 0; |
283 | 280 | ||
284 | XRectangle ink, logical; | 281 | XRectangle ink, logical; |
285 | #ifdef X_HAVE_UTF8_STRING | 282 | #ifdef X_HAVE_UTF8_STRING |
286 | if (m_utf8mode) { | 283 | if (m_utf8mode) { |
287 | Xutf8TextExtents(m_fontset, text.data(), len, | 284 | Xutf8TextExtents(m_fontset, text, len, &ink, &logical); |
288 | &ink, &logical); | ||
289 | if (logical.width != 0) | 285 | if (logical.width != 0) |
290 | return logical.width; | 286 | return logical.width; |
291 | } | 287 | } |
292 | #endif // X_HAVE_UTF8_STRING | 288 | #endif // X_HAVE_UTF8_STRING |
293 | 289 | ||
294 | string localestr = text; | 290 | std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, len)); |
295 | if (len > localestr.length()) | ||
296 | len = localestr.length(); | ||
297 | localestr.erase(len, string::npos); | ||
298 | localestr = FbStringUtil::FbStrToLocale(localestr); | ||
299 | XmbTextExtents(m_fontset, localestr.data(), localestr.size(), | 291 | XmbTextExtents(m_fontset, localestr.data(), localestr.size(), |
300 | &ink, &logical); | 292 | &ink, &logical); |
301 | return logical.width; | 293 | return logical.width; |