Ticket #384: font_hdc.patch
| File font_hdc.patch, 4.0 kB (added by yamazaki, 10 months ago) |
|---|
-
mw32font.c
old new 73 73 74 74 int mw32_lf_loader_num = 0; 75 75 LOADLFPROC mw32_lf_loaders[10]; 76 static HDC mw32_font_hdc = NULL; 76 77 77 78 static Lisp_Object mw32_get_font_request_parameter (Lisp_Object, Lisp_Object); 78 79 … … 189 190 190 191 { 191 192 HANDLE hold; 192 HDC hdc = GetDC (NULL);193 193 194 if (!mw32_font_hdc) 195 mw32_font_hdc = CreateIC ("DISPLAY", NULL, NULL, NULL); 196 194 197 if (pwf->pfont == INVALID_HANDLE_VALUE) 195 198 pwf->pfont = CreateFontIndirect (&pwf->logfont); 196 hold = SelectObject ( hdc, pwf->pfont);199 hold = SelectObject (mw32_font_hdc, pwf->pfont); 197 200 198 201 if (pwf->ttfp) 199 202 { 200 203 ABC abc; 201 int ret = GetCharABCWidths ( hdc, *cp, *cp, &abc);204 int ret = GetCharABCWidths (mw32_font_hdc, *cp, *cp, &abc); 202 205 203 206 if (ret) 204 207 { … … 208 211 } 209 212 else 210 213 { 211 SelectObject (hdc, hold); 212 ReleaseDC (NULL, hdc); 214 SelectObject (mw32_font_hdc, hold); 213 215 return 0; 214 216 } 215 217 } … … 221 223 222 224 p = str; 223 225 SERIALIZE_FONTCP (p, *cp); 224 if (GetTextExtentPoint32 ( hdc, str, p - str, &sz))226 if (GetTextExtentPoint32 (mw32_font_hdc, str, p - str, &sz)) 225 227 { 226 228 pwf->cur_cm.width = sz.cx; 227 229 } 228 230 else 229 231 { 230 232 int w; 231 GetCharWidth ( hdc, *cp, *cp, &w);233 GetCharWidth (mw32_font_hdc, *cp, *cp, &w); 232 234 pwf->cur_cm.width = w; 233 235 } 234 236 pwf->cur_cm.rbearing = pwf->cur_cm.width; … … 238 240 } 239 241 pwf->cur_cm.ascent = plf->ascent; 240 242 pwf->cur_cm.descent = plf->descent; 241 pwf->cur_cm.width += get_device_width ( hdc, plf->character_spacing);243 pwf->cur_cm.width += get_device_width (mw32_font_hdc, plf->character_spacing); 242 244 243 SelectObject (hdc, hold); 244 ReleaseDC (NULL, hdc); 245 SelectObject (mw32_font_hdc, hold); 245 246 } 246 247 if (plf->encoding.font_unit_byte == 1) 247 248 pwf->cmcache[*cp] = pwf->cur_cm; … … 357 358 /* set attributes. */ 358 359 if (hf = CreateFontIndirect (plogf)) 359 360 { 360 HWND hwnd;361 361 HDC hdc; 362 362 HANDLE oldobj; 363 363 TEXTMETRIC tm; … … 512 512 cm.rbearing = 0; 513 513 } 514 514 { 515 HDC hdc = GetDC (NULL); 516 cm.width += get_device_width (hdc, plf->character_spacing); 517 ReleaseDC (NULL, hdc); 515 if (!mw32_font_hdc) 516 mw32_font_hdc = CreateIC ("DISPLAY", NULL, NULL, NULL); 517 518 cm.width += get_device_width (mw32_font_hdc, plf->character_spacing); 518 519 } 519 520 520 521 return &cm; … … 2812 2813 return result; 2813 2814 } 2814 2815 2816 /* clean up */ 2817 void 2818 mw32_font_cleanup (void) 2819 { 2820 if (mw32_font_hdc) 2821 DeleteDC (mw32_font_hdc); 2822 } 2823 2815 2824 /* syms */ 2816 2825 syms_of_mw32font () 2817 2826 { -
mw32font.h
old new 196 196 struct face *face, int c)); 197 197 extern void mw32_delete_logical_font P_ ((MW32LogicalFont *plf)); 198 198 extern void mw32_initialize_default_logfont P_ ((LOGFONT*)); 199 extern void mw32_font_cleanup P_ ((void)); 199 200 200 201 #endif /* __MW32_FONT__ */ -
w32.c
old new 82 82 #include "coding.h" 83 83 #include "mw32reg.h" 84 84 #include "mw32sync.h" 85 #include "mw32font.h" 85 86 86 87 extern Lisp_Object Vfile_name_coding_system; 87 88 #endif … … 4500 4501 term_winsock (); 4501 4502 #endif 4502 4503 4504 #ifdef MEADOW 4505 mw32_font_cleanup (); 4506 #endif 4507 4503 4508 #ifndef MEADOW 4504 4509 term_w32select (); 4505 4510 #endif -
dispnew.c
old new 3900 3900 int paused_p; 3901 3901 struct window *root_window = XWINDOW (f->root_window); 3902 3902 3903 #ifdef MEADOW3904 GET_FRAME_HDC (f);3905 #endif3906 3903 if (redisplay_dont_pause) 3907 3904 force_p = 1; 3908 3905 #if PERIODIC_PREEMPTION_CHECKING … … 4006 4003 add_frame_display_history (f, paused_p); 4007 4004 #endif 4008 4005 } 4009 #ifdef MEADOW4010 RELEASE_FRAME_HDC (f);4011 #endif4012 4006 4013 4007 do_pause: 4014 4008 /* Reset flags indicating that a window should be updated. */
