Pushing this as a possible fix for STR #2622.

This might not be correct (though I think it is) but should be no worse than the current mess I made...

Please test with as many different win32/64 compilers as possible and let me know!




git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8643 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Ian MacArthur
2011-05-10 09:27:18 +00:00
parent 80ea4bcde6
commit eb16787f7a
-5
View File
@@ -282,7 +282,6 @@ void Fl_GDI_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy
} }
static unsigned short *ext_buff = NULL; // UTF-16 converted version of input UTF-8 string static unsigned short *ext_buff = NULL; // UTF-16 converted version of input UTF-8 string
static WCHAR *c_buff = NULL; // glyph class array (if needed)
static WORD *w_buff = NULL; // glyph indices array static WORD *w_buff = NULL; // glyph indices array
static unsigned wc_len = 0; // current string buffer dimensions static unsigned wc_len = 0; // current string buffer dimensions
static const MAT2 matrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } }; // identity mat for GetGlyphOutlineW static const MAT2 matrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } }; // identity mat for GetGlyphOutlineW
@@ -315,11 +314,9 @@ void Fl_GDI_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy
if(len >= wc_len) { if(len >= wc_len) {
if(ext_buff) {delete [] ext_buff;} if(ext_buff) {delete [] ext_buff;}
if(w_buff) {delete [] w_buff;} if(w_buff) {delete [] w_buff;}
if(c_buff) {delete [] c_buff;}
wc_len = len + 64; wc_len = len + 64;
ext_buff = new unsigned short[wc_len]; ext_buff = new unsigned short[wc_len];
w_buff = new WORD[wc_len]; w_buff = new WORD[wc_len];
c_buff = new WCHAR[wc_len];
len = fl_utf8toUtf16(c, n, ext_buff, wc_len); len = fl_utf8toUtf16(c, n, ext_buff, wc_len);
} }
SelectObject(gc, fl_fontsize->fid); SelectObject(gc, fl_fontsize->fid);
@@ -339,10 +336,8 @@ void Fl_GDI_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy
if (has_surrogates) { if (has_surrogates) {
// GetGlyphIndices will not work - use GetCharacterPlacementW() instead // GetGlyphIndices will not work - use GetCharacterPlacementW() instead
GCP_RESULTSW gcp_res; GCP_RESULTSW gcp_res;
memset(c_buff, 0, (sizeof(WCHAR) * wc_len));
memset(w_buff, 0, (sizeof(WORD) * wc_len)); memset(w_buff, 0, (sizeof(WORD) * wc_len));
memset(&gcp_res, 0, sizeof(GCP_RESULTSW)); memset(&gcp_res, 0, sizeof(GCP_RESULTSW));
gcp_res.lpClass = c_buff;
gcp_res.lpGlyphs = (LPWSTR)w_buff; gcp_res.lpGlyphs = (LPWSTR)w_buff;
gcp_res.nGlyphs = wc_len; gcp_res.nGlyphs = wc_len;
gcp_res.lStructSize = sizeof(gcp_res); gcp_res.lStructSize = sizeof(gcp_res);