summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-12-28 21:24:15 +0000
committerManolo Gouy <Manolo>2010-12-28 21:24:15 +0000
commitd3d16a354ea61e9c893193e4ad17acc4316e5ac9 (patch)
tree63d9601091e7d917558e16abf301a583da753837
parent5579dd81cc9984d13763edb2adbcb4b9bf39dc99 (diff)
Win32 right-to-left text: output whole string to obtain correct ligatures between Arabic letters.
This new algorithm is not coherent with fl_width() but allows minimal usage of fl_rtl_draw(). The utf8 demo shows the effect of this change. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8134 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/fl_font_win32.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx
index 285ff8bad..31760c463 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -390,11 +390,6 @@ void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
int wn;
int i = 0;
int lx = 0;
-// if (n > wstr_len) {
-// wstr = (xchar*) realloc(wstr, sizeof(xchar) * (n + 1));
-// wstr_len = n;
-// }
-//wn = fl_utf2unicode((const unsigned char *)c, n, wstr);
wn = fl_utf8toUtf16(c, n, (unsigned short*)wstr, wstr_len);
if(wn >= wstr_len) {
wstr = (xchar*) realloc(wstr, sizeof(xchar) * (wn + 1));
@@ -404,7 +399,8 @@ void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
SelectObject(fl_gc, fl_fontsize->fid);
- while (i < wn) {
+#ifdef RTL_CHAR_BY_CHAR
+ while (i < wn) { // output char by char is very bad for Arabic but coherent with fl_width()
lx = (int) fl_width(wstr[i]);
x -= lx;
TextOutW(fl_gc, x, y, (WCHAR*)wstr + i, 1);
@@ -413,6 +409,11 @@ void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
}
i++;
}
+#else
+ UINT old_align = SetTextAlign(fl_gc, TA_RIGHT | TA_RTLREADING);
+ TextOutW(fl_gc, x, y - fl_height() + fl_descent(), (WCHAR*)wstr, wn);
+ SetTextAlign(fl_gc, old_align);
+#endif
SetTextColor(fl_gc, oldColor);
}
#endif