summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan MacArthur <imacarthur@gmail.com>2011-05-10 15:37:05 +0000
committerIan MacArthur <imacarthur@gmail.com>2011-05-10 15:37:05 +0000
commit41fc90726b12308c96ba310aab8c2871b3e57d44 (patch)
treead46522b9aaf8c3bbdb05923be6eb6481ac79e58 /src
parenteb16787f7aeafb5937de9c418184cbb631ccb553 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/fl_font_win32.cxx3
1 files changed, 3 insertions, 0 deletions
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;
}