comparison src/objects-msw.c @ 276:6330739388db r21-0b36

Import from CVS: tag r21-0b36
author cvs
date Mon, 13 Aug 2007 10:30:37 +0200
parents c5d627a313b1
children 7df0dd720c89
comparison
equal deleted inserted replaced
275:a68ae4439f57 276:6330739388db
1048 { 1048 {
1049 maybe_signal_simple_error ("Couldn't create font", f->name, Qfont, errb); 1049 maybe_signal_simple_error ("Couldn't create font", f->name, Qfont, errb);
1050 return 0; 1050 return 0;
1051 } 1051 }
1052 1052
1053 /* Have to apply Font to a GC to get its values.
1054 * We'll borrow the desktop window becuase its the only window that we
1055 * know about that is guaranteed to exist when this gets called
1056 */
1057 { 1053 {
1058 HWND hwnd;
1059 HDC hdc; 1054 HDC hdc;
1060 HFONT holdfont; 1055 HFONT holdfont;
1061 TEXTMETRIC metrics; 1056 TEXTMETRIC metrics;
1062 1057
1063 hwnd = GetDesktopWindow(); 1058 hdc = CreateCompatibleDC (NULL);
1064 assert(hdc = GetDC(hwnd)); /* XXX FIXME: can this temporarily fail? */ 1059 if (hdc)
1065 holdfont = SelectObject(hdc, f->data); 1060 {
1066 if (!holdfont) 1061 holdfont = SelectObject(hdc, f->data);
1067 { 1062 if (holdfont)
1068 mswindows_finalize_font_instance (f); 1063 {
1069 maybe_signal_simple_error ("Couldn't map font", f->name, Qfont, errb); 1064 GetTextMetrics (hdc, &metrics);
1070 return 0; 1065 SelectObject(hdc, holdfont);
1071 } 1066 DeleteDC (hdc);
1072 GetTextMetrics(hdc, &metrics); 1067 f->width = (unsigned short) metrics.tmAveCharWidth;
1073 SelectObject(hdc, holdfont); 1068 f->height = (unsigned short) metrics.tmHeight;
1074 ReleaseDC(hwnd, hdc); 1069 f->ascent = (unsigned short) metrics.tmAscent;
1075 f->width = (unsigned short) metrics.tmAveCharWidth; 1070 f->descent = (unsigned short) metrics.tmDescent;
1076 f->height = (unsigned short) metrics.tmHeight; 1071 f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH);
1077 f->ascent = (unsigned short) metrics.tmAscent; 1072 return 1;
1078 f->descent = (unsigned short) metrics.tmDescent; 1073 }
1079 f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH); 1074 DeleteDC (hdc);
1075 }
1076 mswindows_finalize_font_instance (f);
1077 maybe_signal_simple_error ("Couldn't map font", f->name, Qfont, errb);
1080 } 1078 }
1081 1079 return 0;
1082 return 1;
1083 } 1080 }
1084 1081
1085 #if 0 1082 #if 0
1086 static void 1083 static void
1087 mswindows_mark_font_instance (struct Lisp_Font_Instance *f, 1084 mswindows_mark_font_instance (struct Lisp_Font_Instance *f,