aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.cc
diff options
context:
space:
mode:
authorKen Bloom <kbloom at gmail com>2010-09-04 13:01:33 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-04 13:01:33 (GMT)
commitea98db414033aa17aee720135e2f9ee0a08696cc (patch)
tree40f0f68ee4a86289d832713890c226f31cdf853a /src/FbTk/Font.cc
parentb1b2f47e7dd185fef88a44a318a9b374083ecb40 (diff)
downloadfluxbox-ea98db414033aa17aee720135e2f9ee0a08696cc.zip
fluxbox-ea98db414033aa17aee720135e2f9ee0a08696cc.tar.bz2
added support for bidirectional text
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r--src/FbTk/Font.cc49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index cbd8250..28341a7 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -248,7 +248,13 @@ bool Font::load(const string &name) {
248} 248}
249 249
250unsigned int Font::textWidth(const FbString &text, unsigned int size) const { 250unsigned int Font::textWidth(const FbString &text, unsigned int size) const {
251 return m_fontimp->textWidth(text, size); 251#ifdef HAVE_FRIBIDI
252 const FbString visualOrder(FbTk::FbStringUtil::BidiLog2Vis(text));
253#else
254 const FbString &visualOrder = text;
255#endif
256
257 return m_fontimp->textWidth(visualOrder, size);
252} 258}
253 259
254unsigned int Font::height() const { 260unsigned int Font::height() const {
@@ -273,31 +279,30 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc,
273 if (text.empty() || len == 0) 279 if (text.empty() || len == 0)
274 return; 280 return;
275 281
276 // so we don't end up in a loop with m_shadow 282#ifdef HAVE_FRIBIDI
277 static bool first_run = true; 283 const FbString visualOrder(FbTk::FbStringUtil::BidiLog2Vis(text));
284#else
285 const FbString &visualOrder = text;
286#endif
287
278 288
279 // draw "effects" first 289 // draw "effects" first
280 if (first_run) { 290 if (m_shadow) {
281 if (m_shadow) { 291 FbTk::GContext shadow_gc(w);
282 FbTk::GContext shadow_gc(w); 292 shadow_gc.setForeground(m_shadow_color);
283 shadow_gc.setForeground(m_shadow_color); 293 m_fontimp->drawText(w, screen, shadow_gc.gc(), visualOrder, len,
284 first_run = false; 294 x + m_shadow_offx, y + m_shadow_offy, orient);
285 drawText(w, screen, shadow_gc.gc(), text, len, 295 } else if (m_halo) {
286 x + m_shadow_offx, y + m_shadow_offy, orient); 296 FbTk::GContext halo_gc(w);
287 first_run = true; 297 halo_gc.setForeground(m_halo_color);
288 } else if (m_halo) { 298 m_fontimp->drawText(w, screen, halo_gc.gc(), visualOrder, len, x + 1, y + 1, orient);
289 FbTk::GContext halo_gc(w); 299 m_fontimp->drawText(w, screen, halo_gc.gc(), visualOrder, len, x - 1, y + 1, orient);
290 halo_gc.setForeground(m_halo_color); 300 m_fontimp->drawText(w, screen, halo_gc.gc(), visualOrder, len, x - 1, y - 1, orient);
291 first_run = false; 301 m_fontimp->drawText(w, screen, halo_gc.gc(), visualOrder, len, x + 1, y - 1, orient);
292 drawText(w, screen, halo_gc.gc(), text, len, x + 1, y + 1, orient);
293 drawText(w, screen, halo_gc.gc(), text, len, x - 1, y + 1, orient);
294 drawText(w, screen, halo_gc.gc(), text, len, x - 1, y - 1, orient);
295 drawText(w, screen, halo_gc.gc(), text, len, x + 1, y - 1, orient);
296 first_run = true;
297 }
298 } 302 }
299 303
300 m_fontimp->drawText(w, screen, gc, text, len, x, y, orient); 304 m_fontimp->drawText(w, screen, gc, visualOrder, len, x, y, orient);
305
301 306
302} 307}
303 308