DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2505
Version: 1.3-current
The Windows backend handles bad UTF-8 sequences by either replacing them
with the replacement character, or guesses that they are ISO
8859-1/CP1252. No such handling is done in the Xft backend though. It
would be nice if this is done for the features above, and for consistency
across platforms if nothing else.
The attached patch changes this by doing a UTF-8 to UCS-2/UCS-4
conversion, which has the side effect of filtering the string.
Link: http://www.fltk.org/str.php?L2505
Version: 1.3-current
diff -up ./src/fl_font_xft.cxx.xft ./src/fl_font_xft.cxx
--- ./src/fl_font_xft.cxx.xft 2010-11-29 19:18:27.000000000 +0100
+++ ./src/fl_font_xft.cxx 2011-01-03 11:52:18.017946001 +0100
@@ -586,7 +586,19 @@ void Fl_Graphics_Driver::draw(const char
color.color.blue = ((int)b)*0x101;
color.color.alpha = 0xffff;
- XftDrawStringUtf8(draw_, &color, current_font, x, y, (XftChar8 *)str, n);
+ wchar_t wstr[n + 1];
+ int count;
+
+ count = fl_utf8towc(str, n, wstr, sizeof(wstr));
+ if (count > sizeof(wstr))
+ return;
+
+ if (sizeof(wchar_t) == sizeof(FcChar32))
+ XftDrawString32(draw_, &color, current_font, x, y, (XftChar32 *)wstr,
count);
+ else if (sizeof(wchar_t) == sizeof(FcChar16))
+ XftDrawString16(draw_, &color, current_font, x, y, (XftChar16 *)wstr,
count);
+ else
+ XftDrawStringUtf8(draw_, &color, current_font, x, y, (XftChar8 *)str, n);
}
void Fl_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y)
{
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs