Hopefully this fixes the bug Albrecht found in using fl_measure on surrogate pairs whilst we were looking at STR #2622.

In summary, if you measured the string *before* the selected font had been used to actually fl_draw() anything, the measurement returned was invalid, as the new font was not "locked in" to the gc.
This change makes sure the selected font is set in the gc before making the measurement.
In tests, this appears to work correctly now...
More opinions welcomed!


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8644 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Ian MacArthur 2011-05-10 15:37:05 +00:00
parent eb16787f7a
commit 41fc90726b

View File

@ -201,6 +201,9 @@ double Fl_GDI_Graphics_Driver::width(unsigned int c) {
unsigned short u16[4]; // Array for UTF16 representation of c
// Creates a UTF16 string from a UCS code point.
cc = fl_ucs_to_Utf16(c, u16, 4);
// Make sure the current font is selected before we make the measurement
SelectObject(fl_gc, fl_fontsize->fid);
// measure the glyph width
GetTextExtentPoint32W(fl_gc, (WCHAR*)u16, cc, &s);
return (double)s.cx;
}