Author: ianmacarthur
Date: 2011-05-10 08:37:05 -0700 (Tue, 10 May 2011)
New Revision: 8644
Log:
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!
Modified:
branches/branch-1.3/src/fl_font_win32.cxx
Modified: branches/branch-1.3/src/fl_font_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_win32.cxx 2011-05-10 09:27:18 UTC (rev
8643)
+++ branches/branch-1.3/src/fl_font_win32.cxx 2011-05-10 15:37:05 UTC (rev
8644)
@@ -201,6 +201,9 @@
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;
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit