diff options
| author | Ian MacArthur <imacarthur@gmail.com> | 2011-04-06 21:37:13 +0000 |
|---|---|---|
| committer | Ian MacArthur <imacarthur@gmail.com> | 2011-04-06 21:37:13 +0000 |
| commit | 8a830853bc8fd74896b5cab9f4b5d290ff48f86a (patch) | |
| tree | 58335709bf358ebee7feaf18d6333b480428acf7 | |
| parent | f7e251e69b3323cb448c2d22c21603c241fcee4d (diff) | |
Further work to fix win32 handling of surrogate pairs for "high" Unicode points... Now fixed handling of rotated text version of win32 draw method.
Fixes to the various ::width() methods for win32 and OSX still TBD.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8568 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/fl_font_win32.cxx | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 9aac9dd2b..82e0075f2 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -373,22 +373,17 @@ void Fl_GDI_Graphics_Driver::draw(const char* str, int n, int x, int y) { void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int y) { fl_font(this, Fl_Graphics_Driver::font(), size(), angle); - int i = 0, i2=0; - char *end = (char *)&str[n]; + int wc_count = 0; // count of UTF16 cells to render full string COLORREF oldColor = SetTextColor(fl_gc, fl_RGB()); SelectObject(fl_gc, font_descriptor()->fid); - //unsigned short ucs[n]; //only GCC, but not MSVC - unsigned short* ucs = new unsigned short[n]; - while (i < n) { - unsigned int u; - int l; - u = fl_utf8decode((const char*)(str + i), end, &l); - ucs[i2] = u; - if (l < 1) l = 1; - i += l; - ++i2; + unsigned short* ucs = new unsigned short[n]; // alloc an array for the UTF16 string + wc_count = fl_utf8toUtf16(str, n, ucs, n); + if(wc_count > n) { // Array too small - this should never happen... + delete[] ucs; // free up the initial allocation + ucs = new unsigned short[wc_count + 4]; // make a "big enough" array + wc_count = fl_utf8toUtf16(str, n, ucs, wc_count); // respin the translation } - TextOutW(fl_gc, x, y, (WCHAR*)ucs, i2); + TextOutW(fl_gc, x, y, (WCHAR*)ucs, wc_count); delete[] ucs; SetTextColor(fl_gc, oldColor); fl_font(this, Fl_Graphics_Driver::font(), size(), 0); |
