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
Attached file "fltk-1_v3.3.x-xft-check.patch"...
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-05 09:47:42.191472266 +0100
@@ -358,6 +358,33 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor(
// XftFontClose(fl_display, font);
}
+static void utf8extents(const char *str, int n, XGlyphInfo *extents)
+{
+
+ wchar_t wstr_buf[1024];
+ wchar_t *wstr;
+ int count;
+
+ memset(extents, 0, sizeof(XGlyphInfo));
+
+ wstr = wstr_buf;
+ count = fl_utf8towc(str, n, wstr, 1024);
+ if (count >= 1024) {
+ wstr = (wchar_t *)malloc((count + 1) * sizeof(wchar_t));
+ count = fl_utf8towc(str, n, wstr, count + 1);
+ }
+
+ if (sizeof(wchar_t) == sizeof(FcChar32))
+ XftTextExtents32(fl_display, current_font, (XftChar32 *)wstr, count,
extents);
+ else if (sizeof(wchar_t) == sizeof(FcChar16))
+ XftTextExtents16(fl_display, current_font, (XftChar16 *)wstr, count,
extents);
+ else
+ XftTextExtentsUtf8(fl_display, current_font, (XftChar8 *)str, n, extents);
+
+ if (wstr != wstr_buf)
+ free(wstr);
+}
+
int fl_height() {
if (current_font) return current_font->ascent + current_font->descent;
else return -1;
@@ -371,7 +398,7 @@ int fl_descent() {
double fl_width(const char *str, int n) {
if (!current_font) return -1.0;
XGlyphInfo i;
- XftTextExtentsUtf8(fl_display, current_font, (XftChar8 *)str, n, &i);
+ utf8extents(str, n, &i);
return i.xOff;
}
@@ -397,7 +424,7 @@ void fl_text_extents(const char *c, int
return;
}
XGlyphInfo gi;
- XftTextExtentsUtf8(fl_display, current_font, (XftChar8 *)c, n, &gi);
+ utf8extents(c, n, &gi);
w = gi.width;
h = gi.height;
@@ -586,7 +613,26 @@ 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_buf[1024];
+ wchar_t *wstr;
+ int count;
+
+ wstr = wstr_buf;
+ count = fl_utf8towc(str, n, wstr, 1024);
+ if (count >= 1024) {
+ wstr = (wchar_t *)malloc((count + 1) * sizeof(wchar_t));
+ count = fl_utf8towc(str, n, wstr, count + 1);
+ }
+
+ 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);
+
+ if (wstr != wstr_buf)
+ free(wstr);
}
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