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
This commit is contained in:
parent
f7e251e69b
commit
8a830853bc
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user