comparison src/w32fns.c @ 94917:e61553aa7a73

Throughout the file, delete all USE_FONT_BACKEND conditionals. Don't check enable_font_backend. Delete all codes used only when USE_FONT_BACKEND is not defined. Surround non-used code by "#ifdef OLD_FONT" and "endif". (Fw32_select_font): Use FONT_COMPAT to get old font structure.
author Kenichi Handa <handa@m17n.org>
date Wed, 14 May 2008 01:04:51 +0000
parents 033cc6f89687
children 8971ddf55736
comparison
equal deleted inserted replaced
94916:283ee643ce8b 94917:e61553aa7a73
60 60
61 #include <dlgs.h> 61 #include <dlgs.h>
62 #include <imm.h> 62 #include <imm.h>
63 #define FILE_NAME_TEXT_FIELD edt1 63 #define FILE_NAME_TEXT_FIELD edt1
64 64
65 #ifdef USE_FONT_BACKEND
66 #include "font.h" 65 #include "font.h"
67 #endif 66 #include "w32font.h"
68 67
69 void syms_of_w32fns (); 68 void syms_of_w32fns ();
70 void globals_of_w32fns (); 69 void globals_of_w32fns ();
71 70
72 extern void free_frame_menubar (); 71 extern void free_frame_menubar ();
73 extern double atof (); 72 extern double atof ();
74 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object)); 73 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object));
75 extern void w32_menu_display_help P_ ((HWND, HMENU, UINT, UINT)); 74 extern void w32_menu_display_help P_ ((HWND, HMENU, UINT, UINT));
76 extern void w32_free_menu_strings P_ ((HWND)); 75 extern void w32_free_menu_strings P_ ((HWND));
76 #if OLD_FONT
77 extern XCharStruct *w32_per_char_metric P_ ((XFontStruct *, wchar_t *, int)); 77 extern XCharStruct *w32_per_char_metric P_ ((XFontStruct *, wchar_t *, int));
78 #endif
78 79
79 extern int quit_char; 80 extern int quit_char;
80 81
81 extern char *lispy_function_keys[]; 82 extern char *lispy_function_keys[];
82 83
340 /* From w32menu.c */ 341 /* From w32menu.c */
341 extern HMENU current_popup_menu; 342 extern HMENU current_popup_menu;
342 static int menubar_in_use = 0; 343 static int menubar_in_use = 0;
343 344
344 /* From w32uniscribe.c */ 345 /* From w32uniscribe.c */
345 #ifdef USE_FONT_BACKEND
346 extern void syms_of_w32uniscribe (); 346 extern void syms_of_w32uniscribe ();
347 extern int uniscribe_available; 347 extern int uniscribe_available;
348 #endif
349 348
350 /* Function prototypes for hourglass support. */ 349 /* Function prototypes for hourglass support. */
351 static void show_hourglass P_ ((struct frame *)); 350 static void show_hourglass P_ ((struct frame *));
352 static void hide_hourglass P_ ((void)); 351 static void hide_hourglass P_ ((void));
353 352
4268 } 4267 }
4269 4268
4270 return Qnil; 4269 return Qnil;
4271 } 4270 }
4272 4271
4273 #ifdef USE_FONT_BACKEND
4274 static void 4272 static void
4275 x_default_font_parameter (f, parms) 4273 x_default_font_parameter (f, parms)
4276 struct frame *f; 4274 struct frame *f;
4277 Lisp_Object parms; 4275 Lisp_Object parms;
4278 { 4276 {
4299 if (NILP (font)) 4297 if (NILP (font))
4300 error ("No suitable font was found"); 4298 error ("No suitable font was found");
4301 } 4299 }
4302 x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING); 4300 x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
4303 } 4301 }
4304 #endif
4305 4302
4306 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 4303 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
4307 1, 1, 0, 4304 1, 1, 0,
4308 doc: /* Make a new window, which is called a \"frame\" in Emacs terms. 4305 doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
4309 Return an Emacs frame object. 4306 Return an Emacs frame object.
4442 } 4439 }
4443 4440
4444 f->resx = dpyinfo->resx; 4441 f->resx = dpyinfo->resx;
4445 f->resy = dpyinfo->resy; 4442 f->resy = dpyinfo->resy;
4446 4443
4447 #ifdef USE_FONT_BACKEND 4444 if (uniscribe_available)
4448 if (enable_font_backend) 4445 register_font_driver (&uniscribe_font_driver, f);
4449 { 4446 register_font_driver (&w32font_driver, f);
4450 /* Perhaps, we must allow frame parameter, say `font-backend', 4447
4451 to specify which font backends to use. */ 4448 x_default_parameter (f, parameters, Qfont_backend, Qnil,
4452 if (uniscribe_available) 4449 "fontBackend", "FontBackend", RES_TYPE_STRING);
4453 register_font_driver (&uniscribe_font_driver, f);
4454 register_font_driver (&w32font_driver, f);
4455
4456 x_default_parameter (f, parameters, Qfont_backend, Qnil,
4457 "fontBackend", "FontBackend", RES_TYPE_STRING);
4458 }
4459 #endif /* USE_FONT_BACKEND */
4460
4461 /* Extract the window parameters from the supplied values 4450 /* Extract the window parameters from the supplied values
4462 that are needed to determine window geometry. */ 4451 that are needed to determine window geometry. */
4463 #ifdef USE_FONT_BACKEND 4452 x_default_font_parameter (f, parameters);
4464 if (enable_font_backend)
4465 x_default_font_parameter (f, parameters);
4466 else
4467 #endif
4468 {
4469 Lisp_Object font;
4470
4471 font = w32_get_arg (parameters, Qfont, "font", "Font", RES_TYPE_STRING);
4472
4473 BLOCK_INPUT;
4474 /* First, try whatever font the caller has specified. */
4475 if (STRINGP (font))
4476 {
4477 tem = Fquery_fontset (font, Qnil);
4478 if (STRINGP (tem))
4479 font = x_new_fontset (f, tem);
4480 else
4481 font = x_new_font (f, SDATA (font));
4482 }
4483 /* Try out a font which we hope has bold and italic variations. */
4484 if (!STRINGP (font))
4485 font = x_new_font (f, "-*-Courier New-normal-r-*-*-*-100-*-*-c-*-iso8859-1");
4486 if (! STRINGP (font))
4487 font = x_new_font (f, "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1");
4488 /* If those didn't work, look for something which will at least work. */
4489 if (! STRINGP (font))
4490 font = x_new_font (f, "-*-Fixedsys-normal-r-*-*-12-*-*-*-c-*-iso8859-1");
4491 UNBLOCK_INPUT;
4492 if (! STRINGP (font))
4493 font = build_string ("Fixedsys");
4494
4495 x_default_parameter (f, parameters, Qfont, font,
4496 "font", "Font", RES_TYPE_STRING);
4497 }
4498
4499 x_default_parameter (f, parameters, Qborder_width, make_number (2), 4453 x_default_parameter (f, parameters, Qborder_width, make_number (2),
4500 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 4454 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
4501 /* This defaults to 2 in order to match xterm. We recognize either 4455 /* This defaults to 2 in order to match xterm. We recognize either
4502 internalBorderWidth or internalBorder (which is what xterm calls 4456 internalBorderWidth or internalBorder (which is what xterm calls
4503 it). */ 4457 it). */
4681 x_focus_on_frame (check_x_frame (frame)); 4635 x_focus_on_frame (check_x_frame (frame));
4682 return Qnil; 4636 return Qnil;
4683 } 4637 }
4684 4638
4685 4639
4640 #if OLD_FONT
4641
4686 /* Return the charset portion of a font name. */ 4642 /* Return the charset portion of a font name. */
4687 char * 4643 char *
4688 xlfd_charset_of_font (char * fontname) 4644 xlfd_charset_of_font (char * fontname)
4689 { 4645 {
4690 char *charset, *encoding; 4646 char *charset, *encoding;
5006 4962
5007 if (font->hfont) DeleteObject (font->hfont); 4963 if (font->hfont) DeleteObject (font->hfont);
5008 xfree (font); 4964 xfree (font);
5009 } 4965 }
5010 } 4966 }
4967 #endif /* OLD_FONT */
5011 4968
5012 /* The font conversion stuff between x and w32 */ 4969 /* The font conversion stuff between x and w32 */
5013 4970
5014 /* X font string is as follows (from faces.el) 4971 /* X font string is as follows (from faces.el)
5015 * (let ((- "[-?]") 4972 * (let ((- "[-?]")
5504 5461
5505 return retval; 5462 return retval;
5506 } 5463 }
5507 } 5464 }
5508 5465
5466 #if OLD_FONT
5467
5509 /* Get the Windows codepage corresponding to the specified font. The 5468 /* Get the Windows codepage corresponding to the specified font. The
5510 charset info in the font name is used to look up 5469 charset info in the font name is used to look up
5511 w32-charset-to-codepage-alist. */ 5470 w32-charset-to-codepage-alist. */
5512 int 5471 int
5513 w32_codepage_for_font (char *fontname) 5472 w32_codepage_for_font (char *fontname)
5559 else if (INTEGERP (codepage)) 5518 else if (INTEGERP (codepage))
5560 return XINT (codepage); 5519 return XINT (codepage);
5561 else 5520 else
5562 return CP_UNKNOWN; 5521 return CP_UNKNOWN;
5563 } 5522 }
5564 5523 #endif /* OLD_FONT */
5565 5524
5566 static BOOL 5525 static BOOL
5567 w32_to_x_font (lplogfont, lpxstr, len, specific_charset) 5526 w32_to_x_font (lplogfont, lpxstr, len, specific_charset)
5568 LOGFONT * lplogfont; 5527 LOGFONT * lplogfont;
5569 char * lpxstr; 5528 char * lpxstr;
5844 /* This makes TrueType fonts work better. */ 5803 /* This makes TrueType fonts work better. */
5845 lplogfont->lfHeight = - eabs (lplogfont->lfHeight); 5804 lplogfont->lfHeight = - eabs (lplogfont->lfHeight);
5846 5805
5847 return (TRUE); 5806 return (TRUE);
5848 } 5807 }
5808
5809 #if OLD_FONT
5849 5810
5850 /* Strip the pixel height and point height from the given xlfd, and 5811 /* Strip the pixel height and point height from the given xlfd, and
5851 return the pixel height. If no pixel height is specified, calculate 5812 return the pixel height. If no pixel height is specified, calculate
5852 one from the point height, or if that isn't defined either, return 5813 one from the point height, or if that isn't defined either, return
5853 0 (which usually signifies a scalable font). 5814 0 (which usually signifies a scalable font).
6558 else 6519 else
6559 fontp->font_encoder = ccl; 6520 fontp->font_encoder = ccl;
6560 } 6521 }
6561 } 6522 }
6562 6523
6524 #endif /* OLD_FONT */
6525
6563 /* directory-files from dired.c. */ 6526 /* directory-files from dired.c. */
6564 Lisp_Object Fdirectory_files P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); 6527 Lisp_Object Fdirectory_files P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object));
6565 6528
6566 6529
6530 #if OLD_FONT
6531
6567 /* Find BDF files in a specified directory. (use GCPRO when calling, 6532 /* Find BDF files in a specified directory. (use GCPRO when calling,
6568 as this calls lisp to get a directory listing). */ 6533 as this calls lisp to get a directory listing). */
6569 static Lisp_Object 6534 static Lisp_Object
6570 w32_find_bdf_fonts_in_dir (Lisp_Object directory) 6535 w32_find_bdf_fonts_in_dir (Lisp_Object directory)
6571 { 6536 {
6612 list = Fnconc ( 2, pair ); 6577 list = Fnconc ( 2, pair );
6613 UNGCPRO; 6578 UNGCPRO;
6614 } 6579 }
6615 return list; 6580 return list;
6616 } 6581 }
6582 #endif /* OLD_FONT */
6617 6583
6618 6584
6619 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, 6585 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
6620 doc: /* Internal function called by `color-defined-p', which see. */) 6586 doc: /* Internal function called by `color-defined-p', which see. */)
6621 (color, frame) 6587 (color, frame)
7082 7048
7083 if (dpyinfo->reference_count > 0) 7049 if (dpyinfo->reference_count > 0)
7084 error ("Display still has frames on it"); 7050 error ("Display still has frames on it");
7085 7051
7086 BLOCK_INPUT; 7052 BLOCK_INPUT;
7053 #if OLD_FONT
7087 /* Free the fonts in the font table. */ 7054 /* Free the fonts in the font table. */
7088 for (i = 0; i < dpyinfo->n_fonts; i++) 7055 for (i = 0; i < dpyinfo->n_fonts; i++)
7089 if (dpyinfo->font_table[i].name) 7056 if (dpyinfo->font_table[i].name)
7090 { 7057 {
7091 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name) 7058 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
7092 xfree (dpyinfo->font_table[i].full_name); 7059 xfree (dpyinfo->font_table[i].full_name);
7093 xfree (dpyinfo->font_table[i].name); 7060 xfree (dpyinfo->font_table[i].name);
7094 w32_unload_font (dpyinfo, dpyinfo->font_table[i].font); 7061 w32_unload_font (dpyinfo, dpyinfo->font_table[i].font);
7095 } 7062 }
7063 #endif
7096 x_destroy_all_bitmaps (dpyinfo); 7064 x_destroy_all_bitmaps (dpyinfo);
7097 7065
7098 x_delete_display (dpyinfo); 7066 x_delete_display (dpyinfo);
7099 UNBLOCK_INPUT; 7067 UNBLOCK_INPUT;
7100 7068
7521 } 7489 }
7522 7490
7523 f->resx = dpyinfo->resx; 7491 f->resx = dpyinfo->resx;
7524 f->resy = dpyinfo->resy; 7492 f->resy = dpyinfo->resy;
7525 7493
7526 #ifdef USE_FONT_BACKEND 7494 /* Perhaps, we must allow frame parameter, say `font-backend',
7527 if (enable_font_backend) 7495 to specify which font backends to use. */
7528 { 7496 register_font_driver (&w32font_driver, f);
7529 /* Perhaps, we must allow frame parameter, say `font-backend', 7497
7530 to specify which font backends to use. */ 7498 x_default_parameter (f, parms, Qfont_backend, Qnil,
7531 register_font_driver (&w32font_driver, f); 7499 "fontBackend", "FontBackend", RES_TYPE_STRING);
7532
7533 x_default_parameter (f, parms, Qfont_backend, Qnil,
7534 "fontBackend", "FontBackend", RES_TYPE_STRING);
7535 }
7536 #endif /* USE_FONT_BACKEND */
7537 7500
7538 /* Extract the window parameters from the supplied values 7501 /* Extract the window parameters from the supplied values
7539 that are needed to determine window geometry. */ 7502 that are needed to determine window geometry. */
7540 #ifdef USE_FONT_BACKEND 7503 x_default_font_parameter (f, parms);
7541 if (enable_font_backend)
7542 x_default_font_parameter (f, parms);
7543 else
7544 #endif /* USE_FONT_BACKEND */
7545 {
7546 Lisp_Object font;
7547
7548 font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
7549
7550 BLOCK_INPUT;
7551 /* First, try whatever font the caller has specified. */
7552 if (STRINGP (font))
7553 {
7554 tem = Fquery_fontset (font, Qnil);
7555 if (STRINGP (tem))
7556 font = x_new_fontset (f, tem);
7557 else
7558 font = x_new_font (f, SDATA (font));
7559 }
7560
7561 /* Try out a font which we hope has bold and italic variations. */
7562 if (!STRINGP (font))
7563 font = x_new_font (f, "-*-Courier New-normal-r-*-*-*-100-*-*-c-*-iso8859-1");
7564 if (! STRINGP (font))
7565 font = x_new_font (f, "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1");
7566 /* If those didn't work, look for something which will at least work. */
7567 if (! STRINGP (font))
7568 font = x_new_font (f, "-*-Fixedsys-normal-r-*-*-12-*-*-*-c-*-iso8859-1");
7569 UNBLOCK_INPUT;
7570 if (! STRINGP (font))
7571 font = build_string ("Fixedsys");
7572
7573 x_default_parameter (f, parms, Qfont, font,
7574 "font", "Font", RES_TYPE_STRING);
7575 }
7576 7504
7577 x_default_parameter (f, parms, Qborder_width, make_number (2), 7505 x_default_parameter (f, parms, Qborder_width, make_number (2),
7578 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 7506 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
7579 /* This defaults to 2 in order to match xterm. We recognize either 7507 /* This defaults to 2 in order to match xterm. We recognize either
7580 internalBorderWidth or internalBorder (which is what xterm calls 7508 internalBorderWidth or internalBorder (which is what xterm calls
8302 cf.lpLogFont = &lf; 8230 cf.lpLogFont = &lf;
8303 8231
8304 /* Initialize as much of the font details as we can from the current 8232 /* Initialize as much of the font details as we can from the current
8305 default font. */ 8233 default font. */
8306 hdc = GetDC (FRAME_W32_WINDOW (f)); 8234 hdc = GetDC (FRAME_W32_WINDOW (f));
8307 oldobj = SelectObject (hdc, FRAME_FONT (f)->hfont); 8235 oldobj = SelectObject (hdc, FONT_COMPAT (FRAME_FONT (f))->hfont);
8308 GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName); 8236 GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName);
8309 if (GetTextMetrics (hdc, &tm)) 8237 if (GetTextMetrics (hdc, &tm))
8310 { 8238 {
8311 lf.lfHeight = tm.tmInternalLeading - tm.tmHeight; 8239 lf.lfHeight = tm.tmInternalLeading - tm.tmHeight;
8312 lf.lfWeight = tm.tmWeight; 8240 lf.lfWeight = tm.tmWeight;
8994 x_set_line_spacing, 8922 x_set_line_spacing,
8995 x_set_fringe_width, 8923 x_set_fringe_width,
8996 x_set_fringe_width, 8924 x_set_fringe_width,
8997 0, /* x_set_wait_for_wm, */ 8925 0, /* x_set_wait_for_wm, */
8998 x_set_fullscreen, 8926 x_set_fullscreen,
8999 #ifdef USE_FONT_BACKEND
9000 x_set_font_backend 8927 x_set_font_backend
9001 #endif
9002 }; 8928 };
9003 8929
9004 void 8930 void
9005 syms_of_w32fns () 8931 syms_of_w32fns ()
9006 { 8932 {
9393 defsubr (&Sw32_unregister_hot_key); 9319 defsubr (&Sw32_unregister_hot_key);
9394 defsubr (&Sw32_registered_hot_keys); 9320 defsubr (&Sw32_registered_hot_keys);
9395 defsubr (&Sw32_reconstruct_hot_key); 9321 defsubr (&Sw32_reconstruct_hot_key);
9396 defsubr (&Sw32_toggle_lock_key); 9322 defsubr (&Sw32_toggle_lock_key);
9397 defsubr (&Sw32_window_exists_p); 9323 defsubr (&Sw32_window_exists_p);
9324 #if OLD_FONT
9398 defsubr (&Sw32_find_bdf_fonts); 9325 defsubr (&Sw32_find_bdf_fonts);
9326 #endif
9399 defsubr (&Sw32_battery_status); 9327 defsubr (&Sw32_battery_status);
9400 9328
9401 defsubr (&Sfile_system_info); 9329 defsubr (&Sfile_system_info);
9402 defsubr (&Sdefault_printer_name); 9330 defsubr (&Sdefault_printer_name);
9403 9331
9332 #if OLD_FONT
9404 /* Setting callback functions for fontset handler. */ 9333 /* Setting callback functions for fontset handler. */
9405 get_font_info_func = w32_get_font_info; 9334 get_font_info_func = w32_get_font_info;
9406 9335
9407 #if 0 /* This function pointer doesn't seem to be used anywhere. 9336 #if 0 /* This function pointer doesn't seem to be used anywhere.
9408 And the pointer assigned has the wrong type, anyway. */ 9337 And the pointer assigned has the wrong type, anyway. */
9412 load_font_func = w32_load_font; 9341 load_font_func = w32_load_font;
9413 find_ccl_program_func = w32_find_ccl_program; 9342 find_ccl_program_func = w32_find_ccl_program;
9414 query_font_func = w32_query_font; 9343 query_font_func = w32_query_font;
9415 set_frame_fontset_func = x_set_font; 9344 set_frame_fontset_func = x_set_font;
9416 get_font_repertory_func = x_get_font_repertory; 9345 get_font_repertory_func = x_get_font_repertory;
9346 #endif
9417 check_window_system_func = check_w32; 9347 check_window_system_func = check_w32;
9418 9348
9419 9349
9420 hourglass_timer = 0; 9350 hourglass_timer = 0;
9421 hourglass_hwnd = NULL; 9351 hourglass_hwnd = NULL;
9474 w32_ansi_code_page = GetACP (); 9404 w32_ansi_code_page = GetACP ();
9475 9405
9476 /* MessageBox does not work without this when linked to comctl32.dll 6.0. */ 9406 /* MessageBox does not work without this when linked to comctl32.dll 6.0. */
9477 InitCommonControls (); 9407 InitCommonControls ();
9478 9408
9479 #ifdef USE_FONT_BACKEND
9480 syms_of_w32uniscribe (); 9409 syms_of_w32uniscribe ();
9481 #endif
9482 } 9410 }
9483 9411
9484 #undef abort 9412 #undef abort
9485 9413
9486 void 9414 void