Fix STR #2553: in function fl_width(unsigned), the SelectObject() statement was

put before making sure we have a valid gc, which was wrong.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8365 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2011-02-03 23:00:30 +00:00
parent fe367d1309
commit 2251609ab3

View File

@ -188,7 +188,6 @@ double fl_width(unsigned int c) {
unsigned int r;
r = (c & 0xFC00) >> 10;
if (!fl_fontsize->width[r]) {
SelectObject(fl_gc, fl_fontsize->fid);
fl_fontsize->width[r] = (int*) malloc(sizeof(int) * 0x0400);
SIZE s;
unsigned short i = 0, ii = r * 0x400;
@ -207,6 +206,7 @@ double fl_width(unsigned int c) {
}
if (!gc)
Fl::fatal("Invalid graphic context: fl_width() failed because no valid HDC was found!");
SelectObject(gc, fl_fontsize->fid);
for (; i < 0x400; i++) {
GetTextExtentPoint32W(gc, (WCHAR*)&ii, 1, &s);
fl_fontsize->width[r][i] = s.cx;