Author: manolo
Date: 2010-12-28 13:24:15 -0800 (Tue, 28 Dec 2010)
New Revision: 8134
Log:
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.
Modified:
branches/branch-1.3/src/fl_font_win32.cxx
Modified: branches/branch-1.3/src/fl_font_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_win32.cxx 2010-12-28 20:28:44 UTC (rev
8133)
+++ branches/branch-1.3/src/fl_font_win32.cxx 2010-12-28 21:24:15 UTC (rev
8134)
@@ -390,11 +390,6 @@
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 @@
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 @@
}
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
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit