diff options
| author | Ian MacArthur <imacarthur@gmail.com> | 2011-04-11 13:13:08 +0000 |
|---|---|---|
| committer | Ian MacArthur <imacarthur@gmail.com> | 2011-04-11 13:13:08 +0000 |
| commit | 4710a6767088ab1dc6f5ab8f1219cd8ce1b09018 (patch) | |
| tree | ddeede4b745fac388c2a82d370cbd92d08c22ba4 /src | |
| parent | 3d9eeb2d44f23d5f8ff36e0f555b4f7bf050839f (diff) | |
Remove use of the MS API call MultiByteToWideChar(...) and re-instate use of fl_utf8toUtf16(...) now that I have fixed a slight off-by-one in handling the ends of the input strings.
This makes string handling much more consistent across variants.
Doh!. I am such an idiot...
NOTE: This still does not fix aberrant handling of surrogate pairs under WinXP, and I still haven't resolved the issues with the win32 ::width() functions not handling surrogate pairs at all...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8575 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -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 5a7eef1d1..711f829da 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -355,9 +355,7 @@ void Fl_GDI_Graphics_Driver::draw(const char* str, int n, int x, int y) { } // Do we need a surrogate pair for this UCS value? if(u > 0xFFFF) { - //cc = fl_utf8toUtf16((str + i), l, ucs, 4); - // This is the MS API equivalent to fl_utf8toUtf16() - cc = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, (str + i), l, (WCHAR*)ucs, 4); + cc = fl_utf8toUtf16((str + i), l, ucs, 4); } else { // not a surrogate pair, use a single value ucs[0] = u; @@ -376,16 +374,13 @@ void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int 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 = new unsigned short[n]; // alloc an array for the UTF16 string - //wc_count = fl_utf8toUtf16(str, n, ucs, n); - // This is the MS API equivalent to fl_utf8toUtf16() - wc_count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str, n, (WCHAR*)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 -// wc_count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str, n, (WCHAR*)ucs, wc_count); -// } + unsigned short* ucs = new unsigned short[n+1]; // 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, wc_count); delete[] ucs; SetTextColor(fl_gc, oldColor); |
