From 41fc90726b12308c96ba310aab8c2871b3e57d44 Mon Sep 17 00:00:00 2001 From: Ian MacArthur Date: Tue, 10 May 2011 15:37:05 +0000 Subject: 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 --- src/fl_font_win32.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 2dca456d5..6348478a2 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -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; } -- cgit v1.2.3